-
-
Notifications
You must be signed in to change notification settings - Fork 830
Fix link modal not shown after access upgrade #12411
Fix link modal not shown after access upgrade #12411
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed locally that this works.
Non-code requests:
- Could the commit message get a line break between after the first line? Without it, the commit title includes the description (and results in a very long title in
git log
). - Could this be rebased on top of
develop
instead of merging with it? The merge makes the commit history a bit more confusing.
89fe0c5
to
8803f1f
Compare
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.
8803f1f
to
7baa85a
Compare
That is interesting. I was displayed correctly in the github commit list. I tried with an actual empty newline inbetween... Maybe that works. Its still shown in my gitlog however. (Is there even a way to show only part of the message in git log)
Sure! We do still merge squash + merge in the react sdk? or did that change? |
const isRoomJoinableFunction = (): boolean => | ||
room.getJoinRule() === JoinRule.Public || (joinRule === JoinRule.Knock && room.canInvite(room.myUserId)); | ||
const isRoomJoinableFunction = (): boolean => { | ||
const joinRule = room.getJoinRule(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't you now shadowing joinRule? If it's the same thing, shouldn't this be a callback that depends on the value of joinRule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AIUI not shadowing the joinRule
is what caused the bug this PR aims to fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we need this to be computed on the fly.
This method is called from a callback that gets created when we show the first modal (asking to change permission rules)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but if it's a different variable, it should generally have a different name rather than shadowing a variable in a higher scope. Wouldn't having it as a dependency make react do the right thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but if it's a different variable, it should generally have a different name rather than shadowing a variable in a higher scope.
That is 100% correct. I see your point now.
I think having the stateVar here does not work because of this
const shareClick = useCallback(() => {
if (isRoomJoinable()) {
showLinkModal();
} else {
// the room needs to be set to public or knock to generate a link
Modal.createDialog(JoinRuleDialog, {
room,
// If the user cannot invite the Knocking is not given as an option.
canInvite,
}).finished.then(() => {
if (isRoomJoinable()) showLinkModal();
});
}
}, [isRoomJoinable, showLinkModal, room, canInvite]);
this line if (isRoomJoinable()) showLinkModal();
would not update the state variable even if it is a dependency since it would capture the variable while it is awaiting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you :)
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.
Checklist
public
/exported
symbols have accurate TSDoc documentation.