feat(core): new worker workspace engine (#9257)
This commit is contained in:
@@ -81,8 +81,8 @@ export class Doc extends Entity {
|
||||
return this.store.waitForDocLoadReady(this.id);
|
||||
}
|
||||
|
||||
setPriorityLoad(priority: number) {
|
||||
return this.store.setPriorityLoad(this.id, priority);
|
||||
addPriorityLoad(priority: number) {
|
||||
return this.store.addPriorityLoad(this.id, priority);
|
||||
}
|
||||
|
||||
changeDocTitle(newTitle: string) {
|
||||
|
||||
@@ -107,7 +107,6 @@ export class DocsService extends Service {
|
||||
) {
|
||||
const doc = this.store.createBlockSuiteDoc();
|
||||
initDocFromProps(doc, options.docProps);
|
||||
this.store.markDocSyncStateAsReady(doc.id);
|
||||
const docRecord = this.list.doc$(doc.id).value;
|
||||
if (!docRecord) {
|
||||
throw new Unreachable();
|
||||
@@ -124,8 +123,9 @@ export class DocsService extends Service {
|
||||
|
||||
async addLinkedDoc(targetDocId: string, linkedDocId: string) {
|
||||
const { doc, release } = this.open(targetDocId);
|
||||
doc.setPriorityLoad(10);
|
||||
const disposePriorityLoad = doc.addPriorityLoad(10);
|
||||
await doc.waitForSyncReady();
|
||||
disposePriorityLoad();
|
||||
const text = new Text([
|
||||
{
|
||||
insert: ' ',
|
||||
@@ -149,8 +149,9 @@ export class DocsService extends Service {
|
||||
|
||||
async changeDocTitle(docId: string, newTitle: string) {
|
||||
const { doc, release } = this.open(docId);
|
||||
doc.setPriorityLoad(10);
|
||||
const disposePriorityLoad = doc.addPriorityLoad(10);
|
||||
await doc.waitForSyncReady();
|
||||
disposePriorityLoad();
|
||||
doc.changeDocTitle(newTitle);
|
||||
release();
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ export class DocsStore extends Store {
|
||||
}
|
||||
|
||||
watchDocListReady() {
|
||||
return this.workspaceService.workspace.engine.rootDocState$
|
||||
.map(state => !state.syncing)
|
||||
.asObservable();
|
||||
return this.workspaceService.workspace.engine.doc
|
||||
.docState$(this.workspaceService.workspace.id)
|
||||
.pipe(map(state => state.synced));
|
||||
}
|
||||
|
||||
setDocMeta(id: string, meta: Partial<DocMeta>) {
|
||||
@@ -153,14 +153,10 @@ export class DocsStore extends Store {
|
||||
}
|
||||
|
||||
waitForDocLoadReady(id: string) {
|
||||
return this.workspaceService.workspace.engine.doc.waitForReady(id);
|
||||
return this.workspaceService.workspace.engine.doc.waitForDocLoaded(id);
|
||||
}
|
||||
|
||||
setPriorityLoad(id: string, priority: number) {
|
||||
return this.workspaceService.workspace.engine.doc.setPriority(id, priority);
|
||||
}
|
||||
|
||||
markDocSyncStateAsReady(id: string) {
|
||||
this.workspaceService.workspace.engine.doc.markAsReady(id);
|
||||
addPriorityLoad(id: string, priority: number) {
|
||||
return this.workspaceService.workspace.engine.doc.addPriority(id, priority);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user