frontend: improve performance when chapters are updated
This commit is contained in:
@@ -113,6 +113,7 @@ export default class MangaUpdatesDataService {
|
|||||||
const series = await dbStore.mangaUpdatesRepository.getSeries();
|
const series = await dbStore.mangaUpdatesRepository.getSeries();
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
const cachedChapterUpdates: MangaUpdatesChapter[] = []
|
||||||
for (const s of series) {
|
for (const s of series) {
|
||||||
try {
|
try {
|
||||||
let groups;
|
let groups;
|
||||||
@@ -141,11 +142,12 @@ export default class MangaUpdatesDataService {
|
|||||||
//only keep chapter with the highest chapter number per group
|
//only keep chapter with the highest chapter number per group
|
||||||
const filtered = Array.from(groupBy(updates, c => c.group).values())
|
const filtered = Array.from(groupBy(updates, c => c.group).values())
|
||||||
.map(chaptersOfGroup => chaptersOfGroup.reduce((l, r) => l.chapter > r.chapter ? l : r, chaptersOfGroup[0]));
|
.map(chaptersOfGroup => chaptersOfGroup.reduce((l, r) => l.chapter > r.chapter ? l : r, chaptersOfGroup[0]));
|
||||||
await mangaStore.updateMangaUpdatesChapters(filtered);
|
cachedChapterUpdates.push(...filtered)
|
||||||
} finally {
|
} finally {
|
||||||
await progress.onProgress('chapters', ++i, series.length);
|
await progress.onProgress('chapters', ++i, series.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await mangaStore.updateMangaUpdatesChapters(cachedChapterUpdates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user