Skip to content

Commit

Permalink
Merge pull request #1504 from gamebeaker/speedup-Library.js
Browse files Browse the repository at this point in the history
Library fix readinglist
  • Loading branch information
gamebeaker authored Sep 23, 2024
2 parents 2c20f0c + ec45d99 commit a6c6668
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 7 additions & 9 deletions plugin/js/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class Library {
constructor() {
}

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

LibAddToLibrary(AddEpub, fileName, overwriteExisting, backgroundDownload){
if (document.getElementById("includeInReadingListCheckbox").checked != true) {
document.getElementById("includeInReadingListCheckbox").click();
Expand Down Expand Up @@ -250,10 +254,8 @@ class Library {
for (let i = 0; i < CurrentLibKeys.length; i++) {
storyurls[i] = items["LibStoryURL" + CurrentLibKeys[i]];
}
let userPreferences = new UserPreferences;
userPreferences = UserPreferences.readFromLocalStorage();
for (let i = 0; i < storyurls.length; i++) {
userPreferences.readingList.tryDeleteEpubAndSave(storyurls[i]);
Library.userPreferences.readingList.tryDeleteEpubAndSave(storyurls[i]);
}
chrome.storage.local.clear();
Library.LibRenderSavedEpubs();
Expand Down Expand Up @@ -646,9 +648,7 @@ class Library {

static LibDeleteEpub(objbtn){
let LibRemove = ["LibEpub" + objbtn.dataset.libepubid, "LibStoryURL" + objbtn.dataset.libepubid, "LibFilename" + objbtn.dataset.libepubid, "LibCover" + objbtn.dataset.libepubid];
let userPreferences = new UserPreferences;
userPreferences = UserPreferences.readFromLocalStorage();
userPreferences.readingList.tryDeleteEpubAndSave(document.getElementById("LibStoryURL" + objbtn.dataset.libepubid).value);
Library.userPreferences.readingList.tryDeleteEpubAndSave(document.getElementById("LibStoryURL" + objbtn.dataset.libepubid).value);
chrome.storage.local.remove(LibRemove);
Library.LibRenderSavedEpubs();
}
Expand Down Expand Up @@ -738,9 +738,7 @@ class Library {
});
HighestLibEpub++;
}
let userPreferences = new UserPreferences;
userPreferences = UserPreferences.readFromLocalStorage();
userPreferences.loadReadingListFromJson(json);
Library.userPreferences.loadReadingListFromJson(json);
Library.LibRenderSavedEpubs();
}

Expand Down
1 change: 1 addition & 0 deletions plugin/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ var main = (function () {

function loadUserPreferences() {
userPreferences = UserPreferences.readFromLocalStorage();
userPreferences.addObserver(library);
userPreferences.writeToUi();
userPreferences.hookupUi();
BakaTsukiSeriesPageParser.registerBakaParsers(userPreferences.autoSelectBTSeriesPage.value);
Expand Down

0 comments on commit a6c6668

Please sign in to comment.