From 6a16637d98d2accb563bf514cf7d2d67ef2c4956 Mon Sep 17 00:00:00 2001 From: Quentin Date: Tue, 23 Jan 2024 21:44:22 +0100 Subject: [PATCH] [Angular] Using Entity 'Refresh list' button makes pagination links multiply requests --- .../_entityFolder_/list/_entityFile_.component.ts.ejs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.ts.ejs b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.ts.ejs index 2338108c1533..15e712e624d5 100644 --- a/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/entities/_entityFolder_/list/_entityFile_.component.ts.ejs @@ -34,7 +34,7 @@ import { Component, inject, OnInit } from '@angular/core'; import { HttpHeaders } from '@angular/common/http'; <%_ } _%> import { ActivatedRoute, Data, ParamMap, Router, RouterModule } from '@angular/router'; -import { combineLatest<%_ if (!readOnly) { _%>, filter<%_ } _%>, Observable, switchMap, tap } from 'rxjs'; +import { combineLatest<%_ if (!readOnly) { _%>, filter<%_ } _%>, Observable, switchMap, Subscription, tap } from 'rxjs'; <%_ if (!readOnly) { _%> import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; <%_ } _%> @@ -121,6 +121,7 @@ export class <%= componentName %> implements OnInit { private static readonly NOT_SORTABLE_FIELDS_AFTER_SEARCH = [<%- notSortableFieldsAfterSearch %>]; <%_ } _%> + subscription: Subscription | null = null; <%= entityInstancePlural %>?: I<%= entityAngularName %>[]; isLoading = false; @@ -227,7 +228,10 @@ export class <%= componentName %> implements OnInit { <%_ } _%> load(): void { - this.loadFromBackendWithRouteInformations().subscribe({ + if (this.subscription !== null) { + this.subscription.unsubscribe(); + } + this.subscription = this.loadFromBackendWithRouteInformations().subscribe({ next: (res: EntityArrayResponseType) => { this.onResponseSuccess(res); }