Skip to content

Commit

Permalink
feat: save correctly the notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezcarlosjr committed Nov 21, 2023
1 parent 41cda2d commit e92cd44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/app/notebook/shell/editorJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ export class EditorJS {

save(): Promise<OutputData> {
return firstValueFrom(this.environment.db.pipe(switchMap((db: RxDatabase) => db["blocks"].find({
selector: {
topic: {
$eq: this.environment.topic ?? ""
}
}
})
.exec()),
selector: {
topic: {
$eq: this.environment.topic ?? ""
},
},
sort: [{index: 'asc'}]
})
.exec()),
map(blocks => {
return blocks.map(doc => {
delete doc._data.crdts
Expand All @@ -43,8 +44,8 @@ export class EditorJS {
})
}),
map(blocks => ({
version: EditorJS.version, blocks
}))));
version: EditorJS.version, blocks
}))));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/notebook/shell/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export class Shell {
const blockCollection = await this.databaseManager.start();
const documents = await firstValueFrom(blockCollection);
let blocks: BlockDocument[] = await this.processDocuments(documents);
if (blocks.length === 0 && !url.has("ps")) {
if (blocks.length === 0 && !url.has("ps") && !url.has("u")) {
blocks.push(this.databaseManager.generateDefaultBlock());
this.databaseManager.upsert(blocks[0]);
}
Expand Down

0 comments on commit e92cd44

Please sign in to comment.