From 5bb304acacbe1a4472a4597f38b595145c9c7af1 Mon Sep 17 00:00:00 2001 From: OtavioStasiak Date: Mon, 16 Dec 2024 14:38:14 -0300 Subject: [PATCH 1/4] fix: prevent setHeader with canEdit true from being overwritten --- app/views/RoomInfoView/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/RoomInfoView/index.tsx b/app/views/RoomInfoView/index.tsx index dd8e92f01c..493ec9ac78 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 setHeader with canEdit set to false from running twice and overwriting a potential setHeader call with canEdit set to true. + 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 = () => From eeab078622206fa082533b1ddefae09f9d3fa973 Mon Sep 17 00:00:00 2001 From: OtavioStasiak Date: Mon, 16 Dec 2024 17:08:21 -0300 Subject: [PATCH 2/4] chore: updated comment --- app/views/RoomInfoView/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/RoomInfoView/index.tsx b/app/views/RoomInfoView/index.tsx index 493ec9ac78..a192f1094c 100644 --- a/app/views/RoomInfoView/index.tsx +++ b/app/views/RoomInfoView/index.tsx @@ -51,7 +51,7 @@ const RoomInfoView = (): React.ReactElement => { const isDirect = roomType === SubscriptionType.DIRECT; const isLivechat = roomType === SubscriptionType.OMNICHANNEL; - // Prevents setHeader with canEdit set to false from running twice and overwriting a potential setHeader call with canEdit set to true. + //prevents overwriting the setHeader after loadRoom . const initialHeaderTitleLoaded = useRef(false); const subscription = useRef(undefined); From 40c9feba001c79e4d55a897c8b7bdc58253a233d Mon Sep 17 00:00:00 2001 From: OtavioStasiak Date: Mon, 16 Dec 2024 17:10:36 -0300 Subject: [PATCH 3/4] fix: lint --- app/views/RoomInfoView/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/RoomInfoView/index.tsx b/app/views/RoomInfoView/index.tsx index a192f1094c..044a70230c 100644 --- a/app/views/RoomInfoView/index.tsx +++ b/app/views/RoomInfoView/index.tsx @@ -51,7 +51,7 @@ const RoomInfoView = (): React.ReactElement => { const isDirect = roomType === SubscriptionType.DIRECT; const isLivechat = roomType === SubscriptionType.OMNICHANNEL; - //prevents overwriting the setHeader after loadRoom . + // Prevents overwriting the setHeader after loadRoom . const initialHeaderTitleLoaded = useRef(false); const subscription = useRef(undefined); From 1250202bc1eed04a4b19f0e5394ba71555ceb0c0 Mon Sep 17 00:00:00 2001 From: OtavioStasiak Date: Mon, 16 Dec 2024 23:48:57 -0300 Subject: [PATCH 4/4] fix: remove space on comment --- app/views/RoomInfoView/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/RoomInfoView/index.tsx b/app/views/RoomInfoView/index.tsx index 044a70230c..51b5eb615e 100644 --- a/app/views/RoomInfoView/index.tsx +++ b/app/views/RoomInfoView/index.tsx @@ -51,7 +51,7 @@ const RoomInfoView = (): React.ReactElement => { const isDirect = roomType === SubscriptionType.DIRECT; const isLivechat = roomType === SubscriptionType.OMNICHANNEL; - // Prevents overwriting the setHeader after loadRoom . + // Prevents overwriting the setHeader after loadRoom. const initialHeaderTitleLoaded = useRef(false); const subscription = useRef(undefined);