mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
feat(core): loading ui for favorite and organize (#7700)
This commit is contained in:
@@ -22,6 +22,25 @@ export {
|
||||
ReadonlyStorage as ReadonlyDocStorage,
|
||||
} from './storage';
|
||||
|
||||
export interface DocEngineDocState {
|
||||
/**
|
||||
* is syncing with the server
|
||||
*/
|
||||
syncing: boolean;
|
||||
/**
|
||||
* is saving to local storage
|
||||
*/
|
||||
saving: boolean;
|
||||
/**
|
||||
* is loading from local storage
|
||||
*/
|
||||
loading: boolean;
|
||||
retrying: boolean;
|
||||
ready: boolean;
|
||||
errorMessage: string | null;
|
||||
serverClock: number | null;
|
||||
}
|
||||
|
||||
export class DocEngine {
|
||||
readonly clientId: string;
|
||||
localPart: DocEngineLocalPart;
|
||||
@@ -53,13 +72,14 @@ export class DocEngine {
|
||||
docState$(docId: string) {
|
||||
const localState$ = this.localPart.docState$(docId);
|
||||
const remoteState$ = this.remotePart?.docState$(docId);
|
||||
return LiveData.computed(get => {
|
||||
return LiveData.computed<DocEngineDocState>(get => {
|
||||
const localState = get(localState$);
|
||||
const remoteState = remoteState$ ? get(remoteState$) : null;
|
||||
if (remoteState) {
|
||||
return {
|
||||
syncing: remoteState.syncing,
|
||||
saving: localState.syncing,
|
||||
loading: localState.syncing,
|
||||
retrying: remoteState.retrying,
|
||||
ready: localState.ready,
|
||||
errorMessage: remoteState.errorMessage,
|
||||
@@ -69,6 +89,7 @@ export class DocEngine {
|
||||
return {
|
||||
syncing: localState.syncing,
|
||||
saving: localState.syncing,
|
||||
loading: localState.syncing,
|
||||
ready: localState.ready,
|
||||
retrying: false,
|
||||
errorMessage: null,
|
||||
|
||||
@@ -40,6 +40,7 @@ export interface LocalEngineState {
|
||||
|
||||
export interface LocalDocState {
|
||||
ready: boolean;
|
||||
loading: boolean;
|
||||
syncing: boolean;
|
||||
}
|
||||
|
||||
@@ -81,6 +82,7 @@ export class DocEngineLocalPart {
|
||||
const next = () => {
|
||||
subscribe.next({
|
||||
ready: this.status.readyDocs.has(docId) ?? false,
|
||||
loading: this.status.connectedDocs.has(docId),
|
||||
syncing:
|
||||
(this.status.jobMap.get(docId)?.length ?? 0) > 0 ||
|
||||
this.status.currentJob?.docId === docId,
|
||||
@@ -91,7 +93,7 @@ export class DocEngineLocalPart {
|
||||
if (updatedId === docId) next();
|
||||
});
|
||||
}),
|
||||
{ ready: false, syncing: false }
|
||||
{ ready: false, loading: false, syncing: false }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user