|
|
|
@ -120,7 +120,7 @@ exports.manga = async (req, res)=>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const filteredArray = chaptersRead.filter(item => item.completely == true);
|
|
|
|
|
const filteredArray = chaptersRead.length>0?chaptersRead.filter(item => item.completely == true):chaptersRead;
|
|
|
|
|
filteredArray.sort((a, b) => a.chapterNum - b.chapterNum);
|
|
|
|
|
const lastCompletelyRead = filteredArray.pop();
|
|
|
|
|
const sortedChapters = chaptersRead.sort((a, b) => a.chapterNum - b.chapterNum);
|
|
|
|
@ -128,11 +128,14 @@ exports.manga = async (req, res)=>
|
|
|
|
|
const lastChapterWithReadImages=sortedAndFilteredChapters.shift();
|
|
|
|
|
let chapterNumToContinue = getChapterNumToContinue(lastCompletelyRead, lastChapterWithReadImages, manga.List);
|
|
|
|
|
if(!manga.List.some(item=> item.num==chapterNumToContinue)) chapterNumToContinue = Math.trunc(chapterNumToContinue);
|
|
|
|
|
let index = manga.List.indexOf(manga.List.filter(item=>
|
|
|
|
|
{
|
|
|
|
|
return item.num == chapterNumToContinue
|
|
|
|
|
})[0]);
|
|
|
|
|
manga.List[index]['continue'] = true;
|
|
|
|
|
if(lastCompletelyRead || lastChapterWithReadImages)
|
|
|
|
|
{
|
|
|
|
|
let index = manga.List.indexOf(manga.List.filter(item=>
|
|
|
|
|
{
|
|
|
|
|
return item.num == chapterNumToContinue
|
|
|
|
|
})[0]);
|
|
|
|
|
manga.List[index]['continue'] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (error)
|
|
|
|
|
{
|
|
|
|
@ -140,8 +143,16 @@ exports.manga = async (req, res)=>
|
|
|
|
|
}
|
|
|
|
|
res.render('mangaPage.ejs', {data:{...manga, scanlator}});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param {Chapter} lastCompletelyRead
|
|
|
|
|
* @param {Chapter} lastChapterWithReadImages
|
|
|
|
|
* @param {ChapterList} List
|
|
|
|
|
* @returns {Nyumber}
|
|
|
|
|
*/
|
|
|
|
|
function getChapterNumToContinue(lastCompletelyRead, lastChapterWithReadImages, List)
|
|
|
|
|
{
|
|
|
|
|
if(!lastCompletelyRead && !lastChapterWithReadImages) return List[0].num;
|
|
|
|
|
const firstIndex = List.indexOf(List.filter(item=>item.num == lastCompletelyRead.chapterNum)[0]);
|
|
|
|
|
if(lastCompletelyRead)
|
|
|
|
|
{
|
|
|
|
|