Skip to content
Permalink
Browse files

Fix local storage save after an update confirm

Remove showNoMal option
  • Loading branch information...
Glagan committed Aug 8, 2019
1 parent 075f616 commit 0139198fbc5b9ae698899446393a03b66d7a4618
Showing with 23 additions and 64 deletions.
  1. +0 −12 options.html
  2. +0 −1 scripts/defaultOptions.js
  3. +21 −43 scripts/myMangaDex.js
  4. +2 −8 scripts/sharedFunctions.js
@@ -178,18 +178,6 @@ <h1 class="text-container py-2 px-2"><i class="fas fa-bookmark"></i> Chapters li
</div>
</div>
</div>
<div class="form-group text-container p-2">
<label class="font-weight-bold">Show no MAL flag <a data-default="showNoMal" class="btn btn-sm btn-secondary"><i class="fas fa-trash"></i><span class="d-none d-xl-inline"> Restore default</span></a></label>
<p class="d-none d-xl-block">Display a tiny flag next to the language flag on a titles list, it indicate that the title has no MyAnimeList ID and you need to manually visit the title page to get the id if it is added.</p>
<div data-option="showNoMal" data-type="checkbox" class="col px-0 my-auto input-group">
<div class="input-group-prepend">
<button type="button" class="btn btn-success input-prepend col px-2">Enabled</button>
</div>
<div class="input-group-append">
<button type="button" class="btn btn-secondary input-append col px-2 active">Disabled</button>
</div>
</div>
</div>
</div>
</div>
<!-- Chapter Page -->
@@ -31,7 +31,6 @@ let defaultOptions = {
highlightChapters: true,
showNotifications: true,
showErrors: true,
showNoMal: true,
onlineSave: false,
onlineURL: "https://mmd.nikurasu.org/api/",
username: "",
@@ -80,7 +80,7 @@ class MyMangaDex {
}
}

async updateMyAnimeList(usePepper=true, setStatus=1, force=false) {
async updateManga(usePepper=true, setStatus=1, force=false) {
if (this.loggedMyAnimeList) {
if (this.manga.is_approved) {
// If the current chapter is higher than the last read one
@@ -97,7 +97,7 @@ class MyMangaDex {
value: "Update", type: "success",
onClick: (notification) => {
notification.close();
this.updateMyAnimeList(usePepper, setStatus, true);
this.updateManga(usePepper, setStatus, true);
}
}, {
value: "Close", type: "error",
@@ -126,7 +126,7 @@ class MyMangaDex {
value: "Update", type: "success",
onClick: (notification) => {
notification.close();
this.updateMyAnimeList(usePepper, setStatus, true);
this.updateManga(usePepper, setStatus, true);
}
}, {
value: "Close", type: "error",
@@ -192,6 +192,17 @@ class MyMangaDex {
this.notification(NOTIFY.INFO, "Not updated", "The manga is still pending approval on MyAnimelist and can't be updated.", this.myAnimeListImage, true);
}
}

// We add the current chapter to the list of opened chapters if the option is on
if (this.options.saveAllOpened && this.manga.currentChapter) {
this.insertChapter(this.manga.currentChapter.chapter);
}
// Update local storage - after, it doesn't really matter
await updateLocalStorage(this.manga, this.options);
// Update History
if (this.options.updateHistoryPage && this.history) {
this.saveCurrentInHistory();
}
}

async quickAddOnMyAnimeList(status) {
@@ -202,7 +213,7 @@ class MyMangaDex {
if (!this.fetched) {
await this.fetchMyAnimeList();
}
await this.updateMyAnimeList(true, status);
await this.updateManga(true, status, true);
this.insertMyAnimeListInformations();
}

@@ -617,7 +628,7 @@ class MyMangaDex {
}
});

await this.updateMyAnimeList(false, status);
await this.updateManga(false, status, true);
if (this.informationsNode != undefined) {
this.insertMyAnimeListInformations();
}
@@ -694,10 +705,10 @@ class MyMangaDex {
this.manga.last_volume = 0;
this.manga.is_rereading = 1;

await this.updateMyAnimeList(false);
await this.updateManga(false);
this.insertMyAnimeListInformations();
this.notification(NOTIFY.SUCCESS, "Re-reading", "You started re-reading **" + this.manga.name + "**", "https://mangadex.org/images/manga/" + this.manga.mangaDexId + ".thumb.jpg");

// Update MangaDex to *Reading*
if (this.options.updateMDList) {
await this.updateMangaDexList("manga_follow", 6);
}
@@ -826,17 +837,6 @@ class MyMangaDex {
for (let chapter in chapters) {
let currentChapter = chapters[chapter].currentChapter.chapter;
let currentRow = chapters[chapter].row;

if (chapter == lastRow && this.options.showNoMal && manga.mal == 0) {
let flag = currentRow.querySelector(".chapter-list-flag.col-auto.text-center.order-lg-4");
let noMal = flag.firstElementChild.cloneNode();
noMal.src = "https://i.imgur.com/n5mQIuH.png";
noMal.classList.remove("flag");
noMal.alt = "No MyAnimeList ID.";
noMal.title = noMal.alt;
flag.appendChild(noMal);
}

// We delete the row if it's lower and one first - or first but all are lower
if (currentChapter > manga.last && this.options.highlightChapters) {
if (sawLastChapter) {
@@ -1207,23 +1207,9 @@ class MyMangaDex {

if (!delayed) {
this.manga.currentChapter = currentChapter;

// Update the Database and maybe MyAnimeList
// Update the local storage and maybe MyAnimeList
if (this.myAnimeListChecked && this.manga.myAnimeListId > 0) {
this.updateMyAnimeList();
}

// We add the current chapter to the list of opened chapters if the option is on
if (this.options.saveAllOpened) {
this.insertChapter(this.manga.currentChapter.chapter);
}

// Update local storage - after, it doesn't really matter
await updateLocalStorage(this.manga, this.options);

// Update History
if (this.options.updateHistoryPage) {
this.saveCurrentInHistory();
this.updateManga();
}
} else {
this.notification(NOTIFY.ERROR, "Chapter Delayed", "The chapter was not updated and saved since it is delayed on MangaDex.", "https://mangadex.org/images/manga/" + this.manga.mangaDexId + ".thumb.jpg");
@@ -1249,18 +1235,10 @@ class MyMangaDex {
if (this.manga.myAnimeListId > 0) {
await this.fetchMyAnimeList();
if (this.manga.exist && this.manga.is_approved) {
await this.updateMyAnimeList();
await this.updateManga();
this.insertMyAnimeListButton(document.querySelector(".reader-controls-actions.col-auto.row.no-gutters.p-1").lastElementChild);
}
}

// Update local storage - after, it doesn't really matter
await updateLocalStorage(this.manga, this.options);

// Update History
if (this.options.updateHistoryPage) {
this.saveCurrentInHistory();
}
} else {
this.notification(NOTIFY.ERROR, "Chapter Delayed", "The chapter was not updated and saved since it is delayed on MangaDex.", "https://mangadex.org/images/manga/" + this.manga.mangaDexId + ".thumb.jpg");
}
@@ -160,21 +160,15 @@ async function loadOptions() {

if (data.subVersion < 6) {
data.saveOnlyNext = false; //.4
data.updateOnlyInList = false;
data.updateOnlyInList = false; // .5
data.confirmChapter = true;
data.showNoMal = undefined;
}

data.subVersion = defaultOptions.subVersion;
}
await storageSet("options", data);
}

// Sub version option fix
if (data.showNoMal === undefined) {
data.showNoMal = defaultOptions.showNoMal;
await storageSet("options", data);
}

return data;
}
}

0 comments on commit 0139198

Please sign in to comment.
You can’t perform that action at this time.