Commit 868197c7 authored by Duhoux Pierre-Louis's avatar Duhoux Pierre-Louis

Fix first chapters list loading on mangarock (CORB issue)

parent 97e15e99
Pipeline #55794314 passed with stages
in 5 minutes and 57 seconds
......@@ -84,9 +84,21 @@ class HandleManga {
} else {
return Promise.resolve();
}
case "loadListChaps":
return this.loadListChaps(message)
}
}
/**
* Loads chapters list
* @param {*} message
*/
async loadListChaps(message) {
let impl = await mirrorsImpl.getImpl(message.mirror);
let lst = await impl.getListChaps(message.url)
return Promise.resolve(lst);
}
/**
* Search mangas on a mirror from search phrase
* @param {*} message
......
......@@ -640,11 +640,22 @@
});
if (alreadyLoadedListChaps && alreadyLoadedListChaps.length > 0) {
this.chapters = alreadyLoadedListChaps.map(arr => { return { url: arr[1], title: arr[0] } })
} else {
let list = []
if (mirrorImpl.get().fromback && mirrorImpl.get().fromback.includes("chaps")) {
// we need to load chapters using background page
list = await browser.runtime.sendMessage({
action: "loadListChaps",
mirror: this.mirror.mirrorName,
url: this.pageData.currentMangaURL,
language: this.pageData.language
});
} else {
// Change currentMangaURL so no conflict in http over https
let list = await mirrorImpl.get().getListChaps(
list = await mirrorImpl.get().getListChaps(
this.pageData.currentMangaURL.replace(/(^\w+:|^)/, '')
)
}
if (list !== undefined && !Array.isArray(list)) { // case of returned list is an object keys are languages and values are list of mangas
if (list[this.manga.language] && list[this.manga.language].length > 0) {
this.chapters = list[this.manga.language].map(arr => { return { url: arr[1], title: arr[0] } })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment