Don't reload errored views with unchanged url when updating views

This commit is contained in:
Max Goodhart
2020-06-19 08:18:31 -07:00
parent b13d3184e8
commit 1c5201e544

View File

@@ -1,5 +1,12 @@
import { Machine, assign } from 'xstate' import { Machine, assign } from 'xstate'
const savePosIfSameURL = {
actions: assign({
pos: (context, event) => event.pos,
}),
cond: 'urlUnchanged',
}
const viewStateMachine = Machine( const viewStateMachine = Machine(
{ {
id: 'view', id: 'view',
@@ -36,12 +43,7 @@ const viewStateMachine = Machine(
url: (context, event) => event.url, url: (context, event) => event.url,
}), }),
on: { on: {
DISPLAY: { DISPLAY: savePosIfSameURL,
actions: assign({
pos: (context, event) => event.pos,
}),
cond: 'urlUnchanged',
},
RELOAD: '.loading', RELOAD: '.loading',
}, },
states: { states: {
@@ -105,6 +107,9 @@ const viewStateMachine = Machine(
}, },
error: { error: {
entry: 'logError', entry: 'logError',
on: {
DISPLAY: savePosIfSameURL,
},
}, },
}, },
}, },