diff --git a/htdocs/vistax.mjs b/htdocs/vistax.mjs index a231612..e8e0649 100644 --- a/htdocs/vistax.mjs +++ b/htdocs/vistax.mjs @@ -10,7 +10,13 @@ if((!state.cid) && (cookie.get('cid'))) state.resources = cookie.get('cid'); if((!state.host) && (cookie.get('host'))) state.resources = cookie.get('host'); if((!state.resources) && (cookie.get('vista.resources'))) state.resources = cookie.get('vista.resources'); if((!state.practitioner) && (cookie.get('vista.practitioner'))) state.practitioner = JSON.parse(cookie.get('vista.practitioner')); -watch(state, value => cookie.set('state', JSON.stringify(value), 45), { immediate: true, deep: true }); +window.addEventListener('storage', function(evt) { + if((evt.storageArea == window.localStorage) && (evt.key == 'state') && (evt.newValue)) Object.assign(state, JSON.parse(evt.newValue)); +}); +watch(state, function(value) { + cookie.set('state', value = JSON.stringify(value), 45); + window.localStorage.setItem('state', value); +}, { immediate: true, deep: true }); function RPCError(type, ...args) { this.name = type;