mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
feat(core): add resetSync button (#10404)
This commit is contained in:
@@ -27,6 +27,7 @@ export interface DocSync {
|
||||
readonly state$: Observable<DocSyncState>;
|
||||
docState$(docId: string): Observable<DocSyncDocState>;
|
||||
addPriority(id: string, priority: number): () => void;
|
||||
resetSync(): Promise<void>;
|
||||
}
|
||||
|
||||
export class DocSyncImpl implements DocSync {
|
||||
@@ -127,4 +128,13 @@ export class DocSyncImpl implements DocSync {
|
||||
const undo = this.peers.map(peer => peer.addPriority(id, priority));
|
||||
return () => undo.forEach(fn => fn());
|
||||
}
|
||||
|
||||
async resetSync() {
|
||||
const running = this.abort !== null;
|
||||
this.stop();
|
||||
await this.sync.clearClocks();
|
||||
if (running) {
|
||||
this.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user