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

Commit

Permalink
Fix link modal not shown after access upgrade (#12411)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
toger5 authored Apr 12, 2024
1 parent 14cc44e commit 313b556
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/room/useGuestAccessInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

0 comments on commit 313b556

Please sign in to comment.