diff options
author | Dan Abramov <dan.abramov@gmail.com> | 2024-05-23 02:09:17 +0100 |
---|---|---|
committer | dan <dan.abramov@gmail.com> | 2024-05-23 03:35:25 +0100 |
commit | acf1def6c1eeea5a717ad76550341d692e92d95c (patch) | |
tree | 0e8a1c52b92c9af5f3e41d3ecf4462e67c437100 /src/state/session/reducer.ts | |
parent | 03655abb7cfbe8fea3f73fc4a298e54364c1de63 (diff) | |
download | voidsky-acf1def6c1eeea5a717ad76550341d692e92d95c.tar.zst |
[Session] Persist updates from inactive agent
Diffstat (limited to 'src/state/session/reducer.ts')
-rw-r--r-- | src/state/session/reducer.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/state/session/reducer.ts b/src/state/session/reducer.ts index 775a6d038..7f3080935 100644 --- a/src/state/session/reducer.ts +++ b/src/state/session/reducer.ts @@ -68,8 +68,13 @@ export function reducer(state: State, action: Action): State { switch (action.type) { case 'received-agent-event': { const {agent, accountDid, refreshedAccount, sessionEvent} = action - if (agent !== state.currentAgentState.agent) { - // Only consider events from the active agent. + if ( + refreshedAccount === undefined && + agent !== state.currentAgentState.agent + ) { + // If the session got cleared out (e.g. due to expiry or network error) but + // this account isn't the active one, don't clear it out at this time. + // This way, if the problem is transient, it'll work on next resume. return state } if (sessionEvent === 'network-error') { |