From 14807897d7d5b7b2a569fcccf5038d7bd1d3ec26 Mon Sep 17 00:00:00 2001 From: LeBalz Date: Fri, 2 Aug 2024 18:03:39 +0200 Subject: [PATCH] display sync state --- src/models/DocumentRoot.ts | 4 ++++ src/models/documents/Script.ts | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/models/DocumentRoot.ts b/src/models/DocumentRoot.ts index a972e8f0..bec5dc12 100644 --- a/src/models/DocumentRoot.ts +++ b/src/models/DocumentRoot.ts @@ -58,6 +58,10 @@ class DocumentRoot { return this.meta.access || this._access; } + get status() { + return this.store.apiStateFor(`load-${this.id}`); + } + @computed get permissions() { return this.store.usersPermissions(this.id); diff --git a/src/models/documents/Script.ts b/src/models/documents/Script.ts index 0e969a3f..a3fd03ed 100644 --- a/src/models/documents/Script.ts +++ b/src/models/documents/Script.ts @@ -23,6 +23,7 @@ import siteConfig from '@generated/docusaurus.config'; import { ScriptMeta } from '@site/src/theme/CodeEditor/WithScript/ScriptContext'; import globalData from '@generated/globalData'; import { ThemeOptions } from 'docusaurus-live-brython'; +import { ApiState } from '@site/src/stores/iStore'; // /** // * Set some configuration options @@ -38,7 +39,7 @@ export default class Script extends iDocument { @observable accessor isExecuting: boolean; @observable accessor showRaw: boolean; @observable accessor isLoaded: boolean; - @observable accessor status: Status = Status.IDLE; + @observable accessor _status: Status = Status.IDLE; @observable accessor isGraphicsmodalOpen: boolean; @observable accessor isPasted: boolean = false; versions = observable.array([], { deep: false }); @@ -101,7 +102,7 @@ export default class Script extends iDocument { /** * call the api to save the code... */ - this.store.save(this); + this.saveNow(); } @action @@ -160,7 +161,7 @@ export default class Script extends iDocument { /** * call the api to save the code... */ - console.log('save now!!!!!'); + this.store.save(this); } /** @@ -233,7 +234,14 @@ export default class Script extends iDocument { } @action setStatus(status: Status) { - this.status = status; + this._status = status; + } + @computed + get status() { + if (this.root.status === ApiState.LOADING) { + return Status.SYNCING; + } + return this._status; } get isVersioned() {