From 305d034626744c81aaaf390e08cac19244c50387 Mon Sep 17 00:00:00 2001 From: Rikudou_Sage Date: Wed, 8 Nov 2023 21:56:28 +0100 Subject: [PATCH] Feat: Add pagination for hesitations (#168) --- .../censure-instance.component.ts | 2 +- .../guarantee-instance.component.ts | 2 +- .../edit-hesitation-reasons.component.ts | 2 +- .../hesitate-on-instance.component.ts | 2 +- .../my-hesitations.component.ts | 4 +- .../censured-instances.component.ts | 5 +- .../hesitated-instances.component.html | 4 +- .../hesitated-instances.component.ts | 89 ++++++++++--------- .../instance-detail.component.ts | 2 +- .../services/cached-fediseer-api.service.ts | 19 +++- src/app/services/fediseer-api.service.ts | 70 ++++++++++++++- .../instance-move-to-list.component.ts | 6 +- .../filter-form/filter-form.component.ts | 2 +- 13 files changed, 148 insertions(+), 61 deletions(-) diff --git a/src/app/censures/pages/censure-instance/censure-instance.component.ts b/src/app/censures/pages/censure-instance/censure-instance.component.ts index 2f68ce7..77e5e19 100644 --- a/src/app/censures/pages/censure-instance/censure-instance.component.ts +++ b/src/app/censures/pages/censure-instance/censure-instance.component.ts @@ -77,7 +77,7 @@ export class CensureInstanceComponent implements OnInit { forkJoin([ this.cachedApi.getGuaranteesByInstance(currentInstance, {clear: true}), this.cachedApi.getAllCensuresByInstances([currentInstance], {clear: true}), - this.cachedApi.getHesitationsByInstances([currentInstance], {clear: true}), + this.cachedApi.getAllHesitationsByInstances([currentInstance], {clear: true}), ]).subscribe(() => { this.loading = false; this.router.navigateByUrl('/censures/my').then(() => { diff --git a/src/app/guarantees/pages/guarantee-instance/guarantee-instance.component.ts b/src/app/guarantees/pages/guarantee-instance/guarantee-instance.component.ts index 20eecef..4e11486 100644 --- a/src/app/guarantees/pages/guarantee-instance/guarantee-instance.component.ts +++ b/src/app/guarantees/pages/guarantee-instance/guarantee-instance.component.ts @@ -52,7 +52,7 @@ export class GuaranteeInstanceComponent implements OnInit { forkJoin([ this.cachedApi.getGuaranteesByInstance(currentInstance, {clear: true}), this.cachedApi.getAllCensuresByInstances([currentInstance], {clear: true}), - this.cachedApi.getHesitationsByInstances([currentInstance], {clear: true}), + this.cachedApi.getAllHesitationsByInstances([currentInstance], {clear: true}), ]).subscribe(() => { this.loading = false; this.router.navigateByUrl('/guarantees/my').then(() => { diff --git a/src/app/hesitations/pages/edit-hesitation-reasons/edit-hesitation-reasons.component.ts b/src/app/hesitations/pages/edit-hesitation-reasons/edit-hesitation-reasons.component.ts index a322578..08090f6 100644 --- a/src/app/hesitations/pages/edit-hesitation-reasons/edit-hesitation-reasons.component.ts +++ b/src/app/hesitations/pages/edit-hesitation-reasons/edit-hesitation-reasons.component.ts @@ -50,7 +50,7 @@ export class EditHesitationReasonsComponent { this.availableReasons = availableReasons; const existing = await toPromise( - this.api.getHesitationsByInstances([this.authManager.currentInstanceSnapshot.name]).pipe( + this.api.getAllHesitationsByInstances([this.authManager.currentInstanceSnapshot.name]).pipe( map(response => { if (this.apiResponseHelper.handleErrors([response])) { return null; diff --git a/src/app/hesitations/pages/hesitate-on-instance/hesitate-on-instance.component.ts b/src/app/hesitations/pages/hesitate-on-instance/hesitate-on-instance.component.ts index a8ff03b..008755e 100644 --- a/src/app/hesitations/pages/hesitate-on-instance/hesitate-on-instance.component.ts +++ b/src/app/hesitations/pages/hesitate-on-instance/hesitate-on-instance.component.ts @@ -75,7 +75,7 @@ export class HesitateOnInstanceComponent implements OnInit { forkJoin([ this.cachedApi.getGuaranteesByInstance(currentInstance, {clear: true}), this.cachedApi.getAllCensuresByInstances([currentInstance], {clear: true}), - this.cachedApi.getHesitationsByInstances([currentInstance], {clear: true}), + this.cachedApi.getAllHesitationsByInstances([currentInstance], {clear: true}), ]).subscribe(() => { this.loading = false; this.router.navigateByUrl('/hesitations/my').then(() => { diff --git a/src/app/hesitations/pages/my-hesitations/my-hesitations.component.ts b/src/app/hesitations/pages/my-hesitations/my-hesitations.component.ts index 462bb35..345f39a 100644 --- a/src/app/hesitations/pages/my-hesitations/my-hesitations.component.ts +++ b/src/app/hesitations/pages/my-hesitations/my-hesitations.component.ts @@ -37,7 +37,7 @@ export class MyHesitationsComponent implements OnInit { this.titleService.title = 'My hesitations'; const responses = await Promise.all([ - toPromise(this.cachedApi.getHesitationsByInstances([this.authManager.currentInstanceSnapshot.name])), + toPromise(this.cachedApi.getAllHesitationsByInstances([this.authManager.currentInstanceSnapshot.name])), toPromise(this.cachedApi.getCurrentInstanceInfo()), ]); @@ -63,7 +63,7 @@ export class MyHesitationsComponent implements OnInit { return; } - this.cachedApi.getHesitationsByInstances([this.authManager.currentInstanceSnapshot.name], {clear: true}).subscribe(); + this.cachedApi.getAllHesitationsByInstances([this.authManager.currentInstanceSnapshot.name], {clear: true}).subscribe(); this.instances = this.instances.filter( hesitatedInstance => hesitatedInstance.domain !== instance, ); diff --git a/src/app/instances/pages/censured-instances/censured-instances.component.ts b/src/app/instances/pages/censured-instances/censured-instances.component.ts index fd51593..25060e0 100644 --- a/src/app/instances/pages/censured-instances/censured-instances.component.ts +++ b/src/app/instances/pages/censured-instances/censured-instances.component.ts @@ -155,7 +155,8 @@ export class CensuredInstancesComponent implements OnInit { } private async getSourceInstances(): Promise { - let sourceInstances = this.filterForm.controls.instances.value ?? environment.defaultCensuresListInstanceFilter; + const originalSourceInstances = this.filterForm.controls.instances.value ?? environment.defaultCensuresListInstanceFilter; + let sourceInstances = originalSourceInstances; if (!sourceInstances.length) { sourceInstances = environment.defaultCensuresListInstanceFilter; } @@ -176,7 +177,7 @@ export class CensuredInstancesComponent implements OnInit { ])]; } if (this.filterForm.controls.includeGuaranteed.value) { - const guaranteed = await Promise.all(sourceInstances.map(async sourceInstance => { + const guaranteed = await Promise.all(originalSourceInstances.map(async sourceInstance => { const guaranteedResponse = await toPromise(this.cachedApi.getGuaranteesByInstance(sourceInstance)); if (this.apiResponseHelper.handleErrors([guaranteedResponse])) { this.loading = false; diff --git a/src/app/instances/pages/hesitated-instances/hesitated-instances.component.html b/src/app/instances/pages/hesitated-instances/hesitated-instances.component.html index f47ff84..efec58c 100644 --- a/src/app/instances/pages/hesitated-instances/hesitated-instances.component.html +++ b/src/app/instances/pages/hesitated-instances/hesitated-instances.component.html @@ -6,7 +6,7 @@
-
+
@@ -91,7 +91,7 @@
-