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