feat(core): show sync state at doc info (#7244)

This commit is contained in:
EYHN
2024-06-18 08:35:22 +00:00
parent ea718d30e9
commit 98258b0211
9 changed files with 154 additions and 41 deletions
+18 -5
View File
@@ -53,12 +53,25 @@ export class DocEngine {
const localState$ = this.localPart.docState$(docId);
const remoteState$ = this.remotePart?.docState$(docId);
return LiveData.computed(get => {
const local = get(localState$);
const remote = remoteState$ ? get(remoteState$) : null;
const localState = get(localState$);
const remoteState = remoteState$ ? get(remoteState$) : null;
if (remoteState) {
return {
syncing: remoteState.syncing,
saving: localState.syncing,
retrying: remoteState.retrying,
ready: localState.ready,
errorMessage: remoteState.errorMessage,
serverClock: remoteState.serverClock,
};
}
return {
ready: local.ready,
saving: local.syncing,
syncing: local.syncing || remote?.syncing,
syncing: localState.syncing,
saving: localState.syncing,
ready: localState.ready,
retrying: false,
errorMessage: null,
serverClock: null,
};
});
}