Skip to content

Commit

Permalink
refactor(playground): remove redundant doc init logic (#8906)
Browse files Browse the repository at this point in the history
  • Loading branch information
doodlewind authored Dec 9, 2024
1 parent b5c4258 commit 831b4c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,8 @@ export class CollabDebugMenu extends SignalWatcher(ShadowlessElement) {
</sl-tooltip>
${new URLSearchParams(location.search).get('room')
? html`<sl-tooltip
content="Your name in Collaboration (default: Unknown)"
placement="bottom"
hoist
><sl-input
placeholder="Unknown"
? html`<sl-input
placeholder="Your name in room"
clearable
size="small"
@blur=${(e: Event) => {
Expand Down
21 changes: 0 additions & 21 deletions packages/playground/apps/default/utils/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,5 @@ export async function initDefaultDocCollection(collection: DocCollection) {
});
doc.addBlock('affine:surface', {}, rootId);
doc.resetHistory();
} else {
// wait for data injected from provider
const firstPageId =
collection.docs.size > 0
? collection.docs.keys().next().value
: await new Promise<string>(resolve =>
collection.slots.docAdded.once(id => resolve(id))
);
if (!firstPageId) {
throw new Error('No first page id found');
}
const doc = collection.getDoc(firstPageId);
if (!doc) {
throw new Error(`Failed to get doc ${firstPageId}`);
}
doc.load();
// wait for data injected from provider
if (!doc.root) {
await new Promise(resolve => doc.slots.rootAdded.once(resolve));
}
doc.resetHistory();
}
}

0 comments on commit 831b4c9

Please sign in to comment.