[Session] Persist updates from inactive agent

This commit is contained in:
Dan Abramov 2024-05-23 02:09:17 +01:00 committed by dan
parent 03655abb7c
commit acf1def6c1
2 changed files with 22 additions and 17 deletions

View file

@ -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') {