Don't clear toasts when changing users #3843
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on the session code I've noticed we have a bunch of weird
setTimeout
s around toasts, and that toasts work poorly when switching accounts in general. Turns out, it's because we unmount them.In this PR, I've relaxed it so that toasts are placed outside the area that gets remounted on user change. As a result, I was able to remove the fragile
setTimeout
hacks. See individual commits.Reviewing
RootSiblingParent
upwards. This is where toasts get mounted on native. I'll assume we only use it for toasts so it's fine to bleed previous users' UI on account change.emitSessionDropped
in theonAgentSessionChange
handler. It seems like it makes sense to show a toast whenever that happens, regardless of the reason (since it can happen out of the blue too). The nativeApp.native.tsx
component already does this bylistenSessionDropped
so this copy-pastes the same approach intoApp.web.tsx
. I presume it wasn't previously enabled due to the remounting issues.useAccountSwitcher
. It will be taken care of by theemitSessionDropped
logic. In fact, this toast isn't even being used yet anyway. It was added in c020a4c#r1584118170 but not hooked up (causeinitSession
never throws atm), and I think we don't need it now either due to the new strategy.Test Plan
Switch accounts on iOS and web. Observe the toast showing up. Try doing it via Settings, via quick switcher, and via the Choose Account screen.
Force session expiry on web using the trick I described in the test plan for #3838. Observe the expiry toast showing up.