Skip to content

Commit

Permalink
107671: Fixed bug where config property would still sometimes be unde…
Browse files Browse the repository at this point in the history
…fined whey calling the ngOnDestroy in the ThemedComponent
  • Loading branch information
alexandrevryghem committed Nov 9, 2023
1 parent da8880e commit 4e54cca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { BehaviorSubject, combineLatest as observableCombineLatest } from 'rxjs';
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';

import { RemoteData } from '../../core/data/remote-data';
import { Collection } from '../../core/shared/collection.model';
Expand Down Expand Up @@ -50,6 +50,8 @@ export class CommunityPageSubCollectionListComponent implements OnInit, OnDestro
*/
subCollectionsRDObs: BehaviorSubject<RemoteData<PaginatedList<Collection>>> = new BehaviorSubject<RemoteData<PaginatedList<Collection>>>({} as any);

subscriptions: Subscription[] = [];

constructor(
protected cds: CollectionDataService,
protected paginationService: PaginationService,
Expand Down Expand Up @@ -77,7 +79,7 @@ export class CommunityPageSubCollectionListComponent implements OnInit, OnDestro
const pagination$ = this.paginationService.getCurrentPagination(this.config.id, this.config);
const sort$ = this.paginationService.getCurrentSort(this.config.id, this.sortConfig);

observableCombineLatest([pagination$, sort$]).pipe(
this.subscriptions.push(observableCombineLatest([pagination$, sort$]).pipe(
switchMap(([currentPagination, currentSort]) => {
return this.cds.findByParent(this.community.id, {
currentPage: currentPagination.currentPage,
Expand All @@ -87,11 +89,12 @@ export class CommunityPageSubCollectionListComponent implements OnInit, OnDestro
})
).subscribe((results) => {
this.subCollectionsRDObs.next(results);
});
}));
}

ngOnDestroy(): void {
this.paginationService.clearPagination(this.config.id);
this.paginationService.clearPagination(this.config?.id);
this.subscriptions.map((subscription: Subscription) => subscription.unsubscribe());
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { BehaviorSubject, combineLatest as observableCombineLatest } from 'rxjs';
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';

import { RemoteData } from '../../core/data/remote-data';
import { Community } from '../../core/shared/community.model';
Expand Down Expand Up @@ -52,6 +52,8 @@ export class CommunityPageSubCommunityListComponent implements OnInit, OnDestroy
*/
subCommunitiesRDObs: BehaviorSubject<RemoteData<PaginatedList<Community>>> = new BehaviorSubject<RemoteData<PaginatedList<Community>>>({} as any);

subscriptions: Subscription[] = [];

constructor(
protected cds: CommunityDataService,
protected paginationService: PaginationService,
Expand Down Expand Up @@ -79,7 +81,7 @@ export class CommunityPageSubCommunityListComponent implements OnInit, OnDestroy
const pagination$ = this.paginationService.getCurrentPagination(this.config.id, this.config);
const sort$ = this.paginationService.getCurrentSort(this.config.id, this.sortConfig);

observableCombineLatest([pagination$, sort$]).pipe(
this.subscriptions.push(observableCombineLatest([pagination$, sort$]).pipe(
switchMap(([currentPagination, currentSort]) => {
return this.cds.findByParent(this.community.id, {
currentPage: currentPagination.currentPage,
Expand All @@ -89,11 +91,12 @@ export class CommunityPageSubCommunityListComponent implements OnInit, OnDestroy
})
).subscribe((results) => {
this.subCommunitiesRDObs.next(results);
});
}));
}

ngOnDestroy(): void {
this.paginationService.clearPagination(this.config.id);
this.paginationService.clearPagination(this.config?.id);
this.subscriptions.map((subscription: Subscription) => subscription.unsubscribe());
}

}

0 comments on commit 4e54cca

Please sign in to comment.