Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 313b556

Browse files
authored
Fix link modal not shown after access upgrade (#12411)
* Fix link modal not shown after access upgrade We dont show the modal since there was a mistake in the isRoomJoinable function. It used a state variable instead of reacomputing the join rule with room.getJoinRule() The state is a captured variable that from before the link share click -> does not update at that time. * dont shadow var
1 parent 14cc44e commit 313b556

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/components/views/rooms/RoomHeader/CallGuestLinkButton.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ export const CallGuestLinkButton: React.FC<{ room: Room }> = ({ room }) => {
7979
// If the user cannot invite the Knocking is not given as an option.
8080
canInvite,
8181
}).finished.then(() => {
82-
// we need to use the function here because the callback got called before the state was updated.
8382
if (isRoomJoinable()) showLinkModal();
8483
});
8584
}

src/hooks/room/useGuestAccessInformation.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ export const useGuestAccessInformation = (room: Room): GuestAccessInformation =>
5252
[canChangeJoinRule, isRoomJoinable, guestSpaUrl],
5353
);
5454

55-
const isRoomJoinableFunction = (): boolean =>
56-
room.getJoinRule() === JoinRule.Public || (joinRule === JoinRule.Knock && room.canInvite(room.myUserId));
55+
const isRoomJoinableFunction = (): boolean => {
56+
const join = room.getJoinRule();
57+
return join === JoinRule.Public || (join === JoinRule.Knock && room.canInvite(room.myUserId));
58+
};
59+
5760
return { canInviteGuests, guestSpaUrl, isRoomJoinable: isRoomJoinableFunction, canInvite };
5861
};

0 commit comments

Comments
 (0)