mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
core: fix attachment not getting detached from note's content
This commit is contained in:
@@ -213,8 +213,8 @@ export class Attachments implements ICollection {
|
||||
if (!localOnly) {
|
||||
await this.detach(attachment);
|
||||
}
|
||||
await this.db.relations.unlinkOfType("attachment", [attachment.id]);
|
||||
await this.collection.softDelete([attachment.id]);
|
||||
await this.db.relations.from(attachment, "note").unlink();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -222,7 +222,7 @@ export class Attachments implements ICollection {
|
||||
|
||||
async detach(attachment: Attachment) {
|
||||
for (const note of await this.db.relations
|
||||
.from(attachment, "note")
|
||||
.to(attachment, "note")
|
||||
.selector.fields(["notes.contentId"])
|
||||
.items()) {
|
||||
if (!note.contentId) continue;
|
||||
@@ -233,7 +233,7 @@ export class Attachments implements ICollection {
|
||||
}
|
||||
|
||||
private async canDetach(attachment: Attachment) {
|
||||
const linkedNotes = await this.db.relations.from(attachment, "note").get();
|
||||
const linkedNotes = await this.db.relations.to(attachment, "note").get();
|
||||
return (
|
||||
(await this.db.relations
|
||||
.to({ ids: linkedNotes.map((n) => n.toId), type: "note" }, "vault")
|
||||
|
||||
Reference in New Issue
Block a user