Skip to content

Commit

Permalink
collection: always update collection card entries
Browse files Browse the repository at this point in the history
  • Loading branch information
shagu committed Feb 3, 2024
1 parent a67f225 commit 34eedd9
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/main/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,17 @@ class Collection {
}

async reload (card, oldurl) {
// same file, doesn't need a reload
if (oldurl && card.fsurl === oldurl) return

// add new card to the collection
this.collection[card.folder].push(card)

// only clean obsolete if old file exists
if (!oldurl) return

// remove old card (if exists)
for (const [folder, contents] of Object.entries(this.collection)) {
for (const card of contents) {
if (card.fsurl === oldurl) this.collection[folder].splice(this.collection[folder].indexOf(card), 1)
// find and remove previous card from collection
if (oldurl) {
for (const [folder, contents] of Object.entries(this.collection)) {
for (const card of contents) {
if (card.fsurl === oldurl) this.collection[folder].splice(this.collection[folder].indexOf(card), 1)
}
}
}

// add updated card to the collection
this.collection[card.folder].push(card)
}

/* add card to current collection */
Expand Down

0 comments on commit 34eedd9

Please sign in to comment.