diff --git a/src/components/views/rooms/RoomHeader/CallGuestLinkButton.tsx b/src/components/views/rooms/RoomHeader/CallGuestLinkButton.tsx index 33170b494b..c5efe10e0f 100644 --- a/src/components/views/rooms/RoomHeader/CallGuestLinkButton.tsx +++ b/src/components/views/rooms/RoomHeader/CallGuestLinkButton.tsx @@ -79,7 +79,6 @@ export const CallGuestLinkButton: React.FC<{ room: Room }> = ({ room }) => { // If the user cannot invite the Knocking is not given as an option. canInvite, }).finished.then(() => { - // we need to use the function here because the callback got called before the state was updated. if (isRoomJoinable()) showLinkModal(); }); } diff --git a/src/hooks/room/useGuestAccessInformation.ts b/src/hooks/room/useGuestAccessInformation.ts index efafcd18d7..38b83700bc 100644 --- a/src/hooks/room/useGuestAccessInformation.ts +++ b/src/hooks/room/useGuestAccessInformation.ts @@ -52,7 +52,10 @@ export const useGuestAccessInformation = (room: Room): GuestAccessInformation => [canChangeJoinRule, isRoomJoinable, guestSpaUrl], ); - const isRoomJoinableFunction = (): boolean => - room.getJoinRule() === JoinRule.Public || (joinRule === JoinRule.Knock && room.canInvite(room.myUserId)); + const isRoomJoinableFunction = (): boolean => { + const join = room.getJoinRule(); + return join === JoinRule.Public || (join === JoinRule.Knock && room.canInvite(room.myUserId)); + }; + return { canInviteGuests, guestSpaUrl, isRoomJoinable: isRoomJoinableFunction, canInvite }; };