mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 22:37:04 +08:00
feat(editor): replace slot with rxjs subject (#10768)
This commit is contained in:
@@ -51,7 +51,7 @@ export function createTestEditor(store: Store, workspace: Workspace) {
|
||||
|
||||
editor.std
|
||||
.get(RefNodeSlotsProvider)
|
||||
.docLinkClicked.on(({ pageId: docId }) => {
|
||||
.docLinkClicked.subscribe(({ pageId: docId }) => {
|
||||
const target = workspace.getDoc(docId);
|
||||
if (!target) {
|
||||
throw new Error(`Failed to jump to doc ${docId}`);
|
||||
|
||||
@@ -9,7 +9,12 @@ export async function prepareTestApp(collection: Workspace) {
|
||||
const store = await getStore(collection, noInit);
|
||||
store.load();
|
||||
if (!store.root) {
|
||||
await new Promise(resolve => store.slots.rootAdded.once(resolve));
|
||||
await new Promise(resolve => {
|
||||
const subscription = store.slots.rootAdded.subscribe(value => {
|
||||
subscription.unsubscribe();
|
||||
resolve(value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
await createTestApp(store, collection);
|
||||
@@ -34,7 +39,7 @@ async function getStore(
|
||||
}
|
||||
|
||||
const { resolve, reject, promise } = Promise.withResolvers<Store>();
|
||||
collection.slots.docListUpdated.on(() => {
|
||||
collection.slots.docListUpdated.subscribe(() => {
|
||||
const doc = collection.docs.values().next().value;
|
||||
const firstDoc = doc?.getStore();
|
||||
if (!firstDoc) {
|
||||
|
||||
Reference in New Issue
Block a user