Skip to content

Commit 4e54cca

Browse files
107671: Fixed bug where config property would still sometimes be undefined whey calling the ngOnDestroy in the ThemedComponent
1 parent da8880e commit 4e54cca

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/app/community-page/sub-collection-list/community-page-sub-collection-list.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
22
import { ActivatedRoute } from '@angular/router';
33

4-
import { BehaviorSubject, combineLatest as observableCombineLatest } from 'rxjs';
4+
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';
55

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

53+
subscriptions: Subscription[] = [];
54+
5355
constructor(
5456
protected cds: CollectionDataService,
5557
protected paginationService: PaginationService,
@@ -77,7 +79,7 @@ export class CommunityPageSubCollectionListComponent implements OnInit, OnDestro
7779
const pagination$ = this.paginationService.getCurrentPagination(this.config.id, this.config);
7880
const sort$ = this.paginationService.getCurrentSort(this.config.id, this.sortConfig);
7981

80-
observableCombineLatest([pagination$, sort$]).pipe(
82+
this.subscriptions.push(observableCombineLatest([pagination$, sort$]).pipe(
8183
switchMap(([currentPagination, currentSort]) => {
8284
return this.cds.findByParent(this.community.id, {
8385
currentPage: currentPagination.currentPage,
@@ -87,11 +89,12 @@ export class CommunityPageSubCollectionListComponent implements OnInit, OnDestro
8789
})
8890
).subscribe((results) => {
8991
this.subCollectionsRDObs.next(results);
90-
});
92+
}));
9193
}
9294

9395
ngOnDestroy(): void {
94-
this.paginationService.clearPagination(this.config.id);
96+
this.paginationService.clearPagination(this.config?.id);
97+
this.subscriptions.map((subscription: Subscription) => subscription.unsubscribe());
9598
}
9699

97100
}

src/app/community-page/sub-community-list/community-page-sub-community-list.component.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
22
import { ActivatedRoute } from '@angular/router';
33

4-
import { BehaviorSubject, combineLatest as observableCombineLatest } from 'rxjs';
4+
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';
55

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

55+
subscriptions: Subscription[] = [];
56+
5557
constructor(
5658
protected cds: CommunityDataService,
5759
protected paginationService: PaginationService,
@@ -79,7 +81,7 @@ export class CommunityPageSubCommunityListComponent implements OnInit, OnDestroy
7981
const pagination$ = this.paginationService.getCurrentPagination(this.config.id, this.config);
8082
const sort$ = this.paginationService.getCurrentSort(this.config.id, this.sortConfig);
8183

82-
observableCombineLatest([pagination$, sort$]).pipe(
84+
this.subscriptions.push(observableCombineLatest([pagination$, sort$]).pipe(
8385
switchMap(([currentPagination, currentSort]) => {
8486
return this.cds.findByParent(this.community.id, {
8587
currentPage: currentPagination.currentPage,
@@ -89,11 +91,12 @@ export class CommunityPageSubCommunityListComponent implements OnInit, OnDestroy
8991
})
9092
).subscribe((results) => {
9193
this.subCommunitiesRDObs.next(results);
92-
});
94+
}));
9395
}
9496

9597
ngOnDestroy(): void {
96-
this.paginationService.clearPagination(this.config.id);
98+
this.paginationService.clearPagination(this.config?.id);
99+
this.subscriptions.map((subscription: Subscription) => subscription.unsubscribe());
97100
}
98101

99102
}

0 commit comments

Comments
 (0)