Skip to content

Commit 546c7de

Browse files
committed
fix Library reset after update
#1910
1 parent ae26bc6 commit 546c7de

3 files changed

Lines changed: 23 additions & 16 deletions

File tree

plugin/js/CoverImageUI.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CoverImageUI {
2727
/** clear all UI elements associated with selecting the Cover Image */
2828
static clearUI() {
2929
CoverImageUI.clearImageTable();
30-
CoverImageUI.setCoverImageUrl(null);
30+
CoverImageUI.setCoverImageUrl("");
3131
}
3232

3333
/** remove all images from the table of images to pick from */

plugin/js/Library.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,12 @@ class Library {
811811
if (document.getElementById("includeInReadingListCheckbox").checked != true) {
812812
document.getElementById("includeInReadingListCheckbox").click();
813813
}
814-
await main.fetchContentAndPackEpub.call(obj);
814+
try {
815+
await main.fetchContentAndPackEpub.call(obj);
816+
} catch {
817+
//
818+
}
819+
Library.LibClearFields();
815820
}
816821

817822
static LibSearchNewChapter(objbtn){
@@ -846,18 +851,12 @@ class Library {
846851
}
847852

848853
static LibClearFields(){
849-
let chapterUrlsUI = new ChapterUrlsUI();
850-
chapterUrlsUI.populateChapterUrlsTable([]);
851-
let ElementsToClear = ["titleInput", "authorInput", "languageInput", "fileNameInput", "coverImageUrlInput", "subjectInput", "descriptionInput"];
852-
for (const element of ElementsToClear) {
853-
document.getElementById(element).value = "";
854-
}
855-
document.getElementById("sampleCoverImg").src = "";
854+
main.resetUI();
856855
}
857856

858857
static async Libupdateall(){
859858
if (document.getElementById("LibDownloadEpubAfterUpdateCheckbox").checked == true) {
860-
document.getElementById("includeInReadingListCheckbox").click();
859+
document.getElementById("LibDownloadEpubAfterUpdateCheckbox").click();
861860
}
862861
let LibArray = await Library.LibGetFromStorage("LibArray");
863862
ErrorLog.SuppressErrorLog = true;
@@ -869,11 +868,13 @@ class Library {
869868
obj.dataset.libsuppressErrorLog = true;
870869
document.getElementById("startingUrlInput").value = await Library.LibGetFromStorage("LibStoryURL" + LibArray[i]);
871870
await main.onLoadAndAnalyseButtonClick.call(obj);
872-
if (document.getElementById("includeInReadingListCheckbox").checked != true) {
873-
document.getElementById("includeInReadingListCheckbox").click();
871+
try {
872+
await main.fetchContentAndPackEpub.call(obj);
873+
} catch {
874+
//
874875
}
875-
await main.fetchContentAndPackEpub.call(obj);
876876
}
877+
Library.LibClearFields();
877878
ErrorLog.SuppressErrorLog = false;
878879
}
879880

@@ -886,7 +887,7 @@ class Library {
886887

887888
static async LibAddListToLibrary(){
888889
if (document.getElementById("LibDownloadEpubAfterUpdateCheckbox").checked == true) {
889-
document.getElementById("includeInReadingListCheckbox").click();
890+
document.getElementById("LibDownloadEpubAfterUpdateCheckbox").click();
890891
}
891892
let links = Library.getURLsFromList();
892893
ErrorLog.SuppressErrorLog = true;
@@ -901,8 +902,13 @@ class Library {
901902
if (document.getElementById("includeInReadingListCheckbox").checked != true) {
902903
document.getElementById("includeInReadingListCheckbox").click();
903904
}
904-
await main.fetchContentAndPackEpub.call(obj);
905+
try {
906+
await main.fetchContentAndPackEpub.call(obj);
907+
} catch {
908+
//
909+
}
905910
}
911+
Library.LibClearFields();
906912
ErrorLog.SuppressErrorLog = false;
907913
}
908914

plugin/js/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ var main = (function () {
620620
return {
621621
getPackEpubButton: getPackEpubButton,
622622
onLoadAndAnalyseButtonClick : onLoadAndAnalyseButtonClick,
623-
fetchContentAndPackEpub: fetchContentAndPackEpub
623+
fetchContentAndPackEpub: fetchContentAndPackEpub,
624+
resetUI: resetUI
624625
};
625626
})();
626627

0 commit comments

Comments
 (0)