fix(messages): don't inherit a stale chat thread across account switch
Switching accounts does location.reload(), which preserves history.state — so the new account re-mounted the Messages module from the previous account's _sub sub-view, whose partnerId belongs to the OLD identity (often the new account's own id → an empty self-thread). Symptom: after switching to the recipient you land on a blank thread and the just-received message never shows (F5 keeps history.state); only going back to the list and reopening the real conversation works. Fix: (1) strip _sub/_ov from history.state before the switch reload so the new account starts at the module root; (2) guard Messages so a thread view with partnerId === meId falls back to the conversation list (can't message yourself).
This commit is contained in:
parent
08e5bb86bf
commit
44093066ec
2 changed files with 11 additions and 1 deletions
|
|
@ -112,6 +112,14 @@ export default function NavSidebar({
|
|||
async function switchTo(id: number) {
|
||||
try {
|
||||
await api.switchAccount(id);
|
||||
// Drop the previous account's in-module sub-view/overlay before the reload (which would
|
||||
// otherwise preserve history.state across the swap). Otherwise the new account lands on a
|
||||
// stale sub-view — e.g. an open chat thread whose partnerId belongs to the OLD identity
|
||||
// (often the new account's own id → an empty self-thread). Start at the module root instead.
|
||||
const st = { ...(window.history.state || {}) };
|
||||
delete st._sub;
|
||||
delete st._ov;
|
||||
window.history.replaceState(st, "");
|
||||
location.reload(); // cleanest way to reload all per-user state for the new account
|
||||
} catch {
|
||||
/* a revoked/removed account — leave the popover open */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue