fix: unlink attachments pn note delete

This commit is contained in:
thecodrr
2022-03-14 15:36:51 +05:00
parent ac20348fa4
commit 8ff8b4331f
2 changed files with 10 additions and 1 deletions

View File

@@ -177,7 +177,7 @@ export default class Attachments extends Collection {
* Get specified type of attachments of a note
* @param {string} noteId
* @param {"files"|"images"|"all"} type
* @returns
* @returns {Array}
*/
ofNote(noteId, type) {
let attachments = [];

View File

@@ -202,6 +202,15 @@ export default class Notes extends Collection {
if (itemData.color) {
await this._db.colors.untag(itemData.color, id);
}
const attachments = this._db.attachments.ofNote(itemData.id, "all");
for (let attachment of attachments) {
await this._db.attachments.delete(
attachment.metadata.hash,
itemData.id
);
}
// await this._collection.removeItem(id);
if (moveToTrash) await this._db.trash.add(itemData);
else {