diff --git a/htdocs/vistax.mjs b/htdocs/vistax.mjs index ebaf5fc..d6440a5 100644 --- a/htdocs/vistax.mjs +++ b/htdocs/vistax.mjs @@ -153,15 +153,16 @@ export function Client(cid, secret) { this.remotestate = reactive({}); this.setup_remotestate = async () => { - var fs = await this.encfs(); + var fs = await this.encfs(), file; try { - Object.assign(this.remotestate, JSON.parse(await fs.cat('state'))); + file = await fs.open('state'); + Object.assign(this.remotestate, JSON.parse(await file.cat(null))); } catch(ex) { console.error(ex); - await fs.create('state', JSON.stringify(this.remotestate)); + file = await fs.create('state', JSON.stringify(this.remotestate)); } watch(this.remotestate, debounce(function(value) { - fs.update('state', JSON.stringify(value)); + file.update(null, JSON.stringify(value)); }, 1000), { deep: true }); if((!this.remotestate.resources) && (localstate.resources)) this.remotestate.resources = localstate.resources; if((!this.remotestate.practitioner) && (localstate.practitioner)) this.remotestate.practitioner = localstate.practitioner;