Skip to content

Commit

Permalink
Merge pull request #1366 from Kiradien/Update-reading-list-status-on-…
Browse files Browse the repository at this point in the history
…delete-epub

#1365 - Update readinglist when removing epub
  • Loading branch information
dteviot authored Jul 3, 2024
2 parents 1daf904 + ea2b904 commit a51214c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugin/js/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class Library {
}
});
}

onUserPreferencesUpdate(userPreferences) {
Library.userPreferences = userPreferences;
}

static async LibMergeEpub(PreviousEpub, AddEpub, LibidURL){
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -618,6 +622,7 @@ class Library {

static LibDeleteEpub(objbtn){
let LibRemove = ["LibEpub" + objbtn.dataset.libepubid, "LibStoryURL" + objbtn.dataset.libepubid, "LibFilename" + objbtn.dataset.libepubid, "LibCover" + objbtn.dataset.libepubid];
Library.userPreferences.readingList.tryDeleteEpubAndSave(document.getElementById("LibStoryURL" + objbtn.dataset.libepubid).value);
chrome.storage.local.remove(LibRemove);
Library.LibRenderSavedEpubs();
}
Expand Down
9 changes: 9 additions & 0 deletions plugin/js/ReadingList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ class ReadingList {
this.epubs.delete(url);
}

tryDeleteEpubAndSave(url) {
if (this.getEpub(url)){
this.deleteEpub(url);
this.writeToLocalStorage();
return true;
}
return false;
}

getEpub(url) {
return this.epubs.get(url);
}
Expand Down
1 change: 1 addition & 0 deletions plugin/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var main = (function () {
if (setParser(url, dom)) {
try {
userPreferences.addObserver(parser);
userPreferences.addObserver(library);
let metaInfo = parser.getEpubMetaInfo(dom, userPreferences.useFullTitle.value);
populateMetaInfo(metaInfo);
setUiToDefaultState();
Expand Down

0 comments on commit a51214c

Please sign in to comment.