Skip to content

Commit

Permalink
display sync state
Browse files Browse the repository at this point in the history
  • Loading branch information
lebalz committed Aug 2, 2024
1 parent 70a9bba commit 1480789
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/models/DocumentRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class DocumentRoot<T extends DocumentType> {
return this.meta.access || this._access;
}

get status() {
return this.store.apiStateFor(`load-${this.id}`);
}

@computed
get permissions() {
return this.store.usersPermissions(this.id);
Expand Down
16 changes: 12 additions & 4 deletions src/models/documents/Script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,7 +39,7 @@ export default class Script extends iDocument<DocumentType.Script> {
@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<Version>([], { deep: false });
Expand Down Expand Up @@ -101,7 +102,7 @@ export default class Script extends iDocument<DocumentType.Script> {
/**
* call the api to save the code...
*/
this.store.save(this);
this.saveNow();
}

@action
Expand Down Expand Up @@ -160,7 +161,7 @@ export default class Script extends iDocument<DocumentType.Script> {
/**
* call the api to save the code...
*/
console.log('save now!!!!!');
this.store.save(this);
}

/**
Expand Down Expand Up @@ -233,7 +234,14 @@ export default class Script extends iDocument<DocumentType.Script> {
}
@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() {
Expand Down

0 comments on commit 1480789

Please sign in to comment.