Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Edit room info button is flickering #6063

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/views/RoomInfoView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const RoomInfoView = (): React.ReactElement => {
const isDirect = roomType === SubscriptionType.DIRECT;
const isLivechat = roomType === SubscriptionType.OMNICHANNEL;

// Prevents overwriting the setHeader after loadRoom.
const initialHeaderTitleLoaded = useRef<boolean>(false);
const subscription = useRef<Subscription | undefined>(undefined);

const {
Expand Down Expand Up @@ -79,7 +81,9 @@ const RoomInfoView = (): React.ReactElement => {

// Prevents from flashing RoomInfoView on the header title before fetching actual room data
useLayoutEffect(() => {
if (initialHeaderTitleLoaded.current) return;
setHeader(false);
initialHeaderTitleLoaded.current = true;
});

useEffect(() => {
Expand Down Expand Up @@ -196,7 +200,7 @@ const RoomInfoView = (): React.ReactElement => {
const sub = subRoom.observe();
subscription.current = sub.subscribe(changes => {
setRoom(changes.asPlain());
setHeader((roomType === SubscriptionType.DIRECT) ? false : canEdit);
setHeader(roomType === SubscriptionType.DIRECT ? false : canEdit);
});
} else {
try {
Expand All @@ -209,7 +213,7 @@ const RoomInfoView = (): React.ReactElement => {
}
}
setShowEdit(canEdit);
setHeader((roomType === SubscriptionType.DIRECT) ? false : canEdit);
setHeader(roomType === SubscriptionType.DIRECT ? false : canEdit);
};

const createDirect = () =>
Expand Down