frontend: improve performance when chapters are updated

This commit is contained in:
wea_ondara
2023-11-22 16:59:17 +01:00
parent 67e4c606ea
commit df705e5e20

View File

@@ -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);
} }
} }