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
|
|
@ -22,7 +22,9 @@ export default function Messages({ meId }: { meId: number }) {
|
|||
// the module (open() pushes an entry; back() = history.back()).
|
||||
const { view, open, back } = useHistorySubview<View>("list");
|
||||
|
||||
if (typeof view === "object") {
|
||||
// Guard against a stale sub-view whose partnerId is the current user's own id (you can't
|
||||
// message yourself). This can be inherited across an account switch — fall back to the list.
|
||||
if (typeof view === "object" && view.partnerId !== meId) {
|
||||
return (
|
||||
<PageThread
|
||||
meId={meId}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue