core: always delete vault references on vault deletion

This commit is contained in:
Abdullah Atta
2024-02-24 12:22:11 +05:00
parent d34ff63016
commit 989203dec6
5 changed files with 4 additions and 6 deletions

View File

@@ -185,7 +185,7 @@ test("delete vault without deleting all locked notes", () =>
await db.vault.delete();
expect(await db.relations.from(vault, "note").has(id)).toBe(true);
expect(await db.relations.from(vault, "note").has(id)).toBe(false);
expect(await db.vaults.default()).toBeUndefined();
}));

View File

@@ -160,7 +160,7 @@ export default class Vault {
await this.db.notes.remove(...lockedIds);
}
await this.db.vaults.remove(vault.id, deleteAllLockedNotes);
await this.db.vaults.remove(vault.id);
this.password = undefined;
}

View File

@@ -138,7 +138,6 @@ export class Notes implements ICollection {
headline: headline,
pinned: item.pinned,
locked: item.locked,
favorite: item.favorite,
localOnly: item.localOnly,
conflicted: item.conflicted,

View File

@@ -55,9 +55,9 @@ export class Vaults implements ICollection {
return id;
}
async remove(id: string, unlinkAllNotes = false) {
async remove(id: string) {
await this.db.transaction(async () => {
if (unlinkAllNotes) await this.db.relations.unlinkOfType("vault", [id]);
await this.db.relations.unlinkOfType("vault", [id]);
await this.collection.softDelete([id]);
});
}

View File

@@ -50,7 +50,6 @@ export class NNMigrationProvider implements MigrationProvider {
.addColumn("headline", "text")
.addColumn("contentId", "text")
.addColumn("pinned", "boolean")
.addColumn("locked", "boolean")
.addColumn("favorite", "boolean")
.addColumn("localOnly", "boolean")
.addColumn("conflicted", "boolean")