mirror of
https://github.com/danbulant/Mangades
synced 2026-07-06 03:20:42 +00:00
speed improvements
This commit is contained in:
parent
69f1da1fec
commit
56f1d3cca2
3 changed files with 41 additions and 26 deletions
|
|
@ -8,6 +8,13 @@
|
||||||
|
|
||||||
var isLoading = false;
|
var isLoading = false;
|
||||||
async function find(entry) {
|
async function find(entry) {
|
||||||
|
if(typeof localStorage !== "undefined") {
|
||||||
|
let cache = localStorage.getItem("anilist-mangadex-" + entry.media.id);
|
||||||
|
if(cache) {
|
||||||
|
goto("./" + cache);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
var query = new URLSearchParams();
|
var query = new URLSearchParams();
|
||||||
query.set("title", entry.media.title.romaji);
|
query.set("title", entry.media.title.romaji);
|
||||||
|
|
@ -33,6 +40,9 @@
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if(typeof localStorage !== "undefined") {
|
||||||
|
localStorage.setItem("anilist-mangadex-" + entry.media.id, item.id);
|
||||||
|
}
|
||||||
goto("./" + item.id);
|
goto("./" + item.id);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,11 @@ export function getUserDetails() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mangaCache;
|
||||||
export function getUserManga() {
|
export function getUserManga() {
|
||||||
const id = getUserID();
|
const id = getUserID();
|
||||||
return makeRequest(`
|
if(mangaCache) return mangaCache;
|
||||||
|
return mangaCache = makeRequest(`
|
||||||
query($id: Int) {
|
query($id: Int) {
|
||||||
MediaListCollection(userId: $id, type: MANGA) {
|
MediaListCollection(userId: $id, type: MANGA) {
|
||||||
lists {
|
lists {
|
||||||
|
|
|
||||||
|
|
@ -246,33 +246,36 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const anilistCache = new Map();
|
||||||
function anilistInfo(id) {
|
function anilistInfo(id) {
|
||||||
return makeRequest(`
|
if(!anilistCache.has(id))
|
||||||
query ($id: Int) {
|
anilistCache.set(id, makeRequest(`
|
||||||
Media(id: $id, format: MANGA) {
|
query ($id: Int) {
|
||||||
id
|
Media(id: $id, format: MANGA) {
|
||||||
type
|
id
|
||||||
format
|
type
|
||||||
status
|
format
|
||||||
chapters
|
status
|
||||||
volumes
|
chapters
|
||||||
countryOfOrigin
|
volumes
|
||||||
bannerImage
|
countryOfOrigin
|
||||||
genres
|
bannerImage
|
||||||
synonyms
|
genres
|
||||||
averageScore
|
synonyms
|
||||||
popularity
|
averageScore
|
||||||
isFavourite
|
popularity
|
||||||
isFavouriteBlocked
|
isFavourite
|
||||||
isAdult
|
isFavouriteBlocked
|
||||||
siteUrl
|
isAdult
|
||||||
coverImage {
|
siteUrl
|
||||||
large
|
coverImage {
|
||||||
medium
|
large
|
||||||
color
|
medium
|
||||||
|
color
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}`, { id }).then(t => t.data.Media));
|
||||||
}`, { id }).then(t => t.data.Media);
|
return anilistCache.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
let anilistData;
|
let anilistData;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue