mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
core: removeFromAllNotebooks should unlink notebook relations too
This commit is contained in:
committed by
Abdullah Atta
parent
d7a126ab85
commit
efc678d3cd
@@ -374,7 +374,7 @@ export default class Notes extends Collection {
|
||||
async removeFromAllNotebooks(...noteIds) {
|
||||
for (const noteId of noteIds) {
|
||||
const note = this.note(noteId);
|
||||
if (!note || note.deleted || !note.notebooks) {
|
||||
if (!note || note.deleted) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -382,6 +382,7 @@ export default class Notes extends Collection {
|
||||
id: noteId,
|
||||
notebooks: []
|
||||
});
|
||||
await this._db.relations.unlinkAll(note.data, "notebook");
|
||||
}
|
||||
this.topicReferences.rebuild();
|
||||
}
|
||||
|
||||
@@ -142,6 +142,19 @@ export default class Relations extends Collection {
|
||||
await this.remove(relation.id);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {ItemReference} from
|
||||
* @param {string} type
|
||||
*/
|
||||
async unlinkAll(to, type) {
|
||||
for (const relation of this.all.filter(
|
||||
(a) => compareItemReference(a.to, to) && a.from.type === type
|
||||
)) {
|
||||
await this.remove(relation.id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Relation[]} relations
|
||||
* @param {"from" | "to"} resolveType
|
||||
|
||||
Reference in New Issue
Block a user