diff --git a/app/views/RoomInfoView/index.tsx b/app/views/RoomInfoView/index.tsx index dd8e92f01c..51b5eb615e 100644 --- a/app/views/RoomInfoView/index.tsx +++ b/app/views/RoomInfoView/index.tsx @@ -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(false); const subscription = useRef(undefined); const { @@ -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(() => { @@ -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 { @@ -209,7 +213,7 @@ const RoomInfoView = (): React.ReactElement => { } } setShowEdit(canEdit); - setHeader((roomType === SubscriptionType.DIRECT) ? false : canEdit); + setHeader(roomType === SubscriptionType.DIRECT ? false : canEdit); }; const createDirect = () =>