From 2f54e8f1f1a2a0f2d705f8b46c7de008bae5e03c Mon Sep 17 00:00:00 2001 From: mytlogos Date: Tue, 3 May 2022 13:40:52 +0200 Subject: [PATCH] feat(website): only necessary progress updates --- packages/website/src/views/MediumDetail.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/website/src/views/MediumDetail.vue b/packages/website/src/views/MediumDetail.vue index feb1fd5c..24f6f4ca 100644 --- a/packages/website/src/views/MediumDetail.vue +++ b/packages/website/src/views/MediumDetail.vue @@ -536,8 +536,23 @@ export default defineComponent({ const newProgress = read ? 1 : 0; const batchSize = 50; + let updateReleases = []; + + if (read) { + updateReleases = this.releases.filter((value) => value.progress < 1); + } else { + updateReleases = this.releases.filter((value) => value.progress >= 1); + } + + if (!updateReleases.length) { + this.markToast.message = "No Releases available for marking."; + this.markToast.success = true; + this.markToast.show = true; + return; + } + Promise.allSettled( - batch(this.releases, batchSize).map((releases: MediumRelease[]) => { + batch(updateReleases, batchSize).map((releases: MediumRelease[]) => { const episodeIds: number[] = releases.map((value) => value.episodeId); return HttpClient.updateProgress(episodeIds, newProgress); }),