-
-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent re-rendering of account sidebar when switching account #3789
Prevent re-rendering of account sidebar when switching account #3789
Conversation
This might cause the chat state to be temporarily invalid, right? I can see how switching the account id will not reset the chat id to |
I used a ref instead of refactoring and moving the component up. |
75eb957
to
bc6c55b
Compare
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.
Ehh, looks a little fragile. We reset all state of ChatProvider
with unselectChat
, but <ContextMenuProvider>
, <DialogContextProvider>
etc also have their state that could become invalid, don't they?
Maybe just keeping the scroll position is good enough for now? With Though if you're sure it's all good, I won't insist. I'm just voicing my thoughts. |
@@ -129,6 +130,9 @@ export default class ScreenController extends Component { | |||
if (this.selectedAccountId === undefined) { | |||
return | |||
} | |||
|
|||
this.unselectChatRef.current?.() |
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.
What does this mean here? Looks weird to me :)
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.
The function is set from inside ChatContext
. Read it as chatContext.unselectChat()
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.
An alternative to doing it like that is to introduce the unselectChat
as a prop to the classic class-style React component:
I guess yes in theory: a dialog like settings could still be open when you switch account from a notification that was for another account.
no, because:
|
The only way to switch accounts without clicking in the interface (which means no context menu / dialog can be open at the same time), is to click on a notification that is for another account (I just added a commit to close all dialogs in that case). (At least to according to my current knowledge.) |
Fixes problem where changing account set chat id of previous account to new account as last selected chat id, which selected a random chat in the account you switched to because the selected id came from previous account.
f37baf1
to
58fac03
Compare
Closes #3776
Alternative to #3787 (which showed caching issues when switching accounts)
The only thing that is a bit annoying in terms of flickering now are the gallery tabs (when the experimental feature location streaming is enabled), though that is only minor, we could solve that by splitting the setting store up in one that caches account setting and another one that caches config.json/DesktopSettings, the latter stores the experimental option for location streaming and does not need to be reloaded everytime the account id changes.