Cross-tab state synchronization with localStorage
This commit is contained in:
		| @@ -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.host) && (cookie.get('host'))) state.resources = cookie.get('host'); | ||||||
| if((!state.resources) && (cookie.get('vista.resources'))) state.resources = cookie.get('vista.resources'); | 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')); | 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) { | function RPCError(type, ...args) { | ||||||
| 	this.name = type; | 	this.name = type; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user