From c94785a94f2f2d4fa9f6c3d71feaaa2f51c716f2 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Thu, 24 Nov 2022 12:38:38 +0100 Subject: [PATCH] MOBILE-4081 addons: Delete manager instances This prevents errors for trying to get the source of a destroyed manager (for example, for subsequent asynchronous calls fetching data). --- src/addons/calendar/components/calendar/calendar.ts | 4 +++- src/addons/calendar/pages/day/day.page.ts | 4 +++- src/addons/mod/book/pages/contents/contents.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/addons/calendar/components/calendar/calendar.ts b/src/addons/calendar/components/calendar/calendar.ts index 1e8bf8d73..aef2a3a74 100644 --- a/src/addons/calendar/components/calendar/calendar.ts +++ b/src/addons/calendar/components/calendar/calendar.ts @@ -340,7 +340,9 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro ngOnDestroy(): void { this.undeleteEventObserver?.off(); this.manager?.destroy(); - this.managerUnsubscribe && this.managerUnsubscribe(); + this.managerUnsubscribe?.(); + + delete this.manager; } } diff --git a/src/addons/calendar/pages/day/day.page.ts b/src/addons/calendar/pages/day/day.page.ts index 839a3a7d5..3c266ee85 100644 --- a/src/addons/calendar/pages/day/day.page.ts +++ b/src/addons/calendar/pages/day/day.page.ts @@ -457,7 +457,9 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy { this.filterChangedObserver?.off(); this.manager?.getSource().forgetRelatedSources(); this.manager?.destroy(); - this.managerUnsubscribe && this.managerUnsubscribe(); + this.managerUnsubscribe?.(); + + delete this.manager; } } diff --git a/src/addons/mod/book/pages/contents/contents.ts b/src/addons/mod/book/pages/contents/contents.ts index fef0d3775..9c290473e 100644 --- a/src/addons/mod/book/pages/contents/contents.ts +++ b/src/addons/mod/book/pages/contents/contents.ts @@ -314,8 +314,10 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy { * @inheritdoc */ ngOnDestroy(): void { - this.managerUnsubscribe && this.managerUnsubscribe(); this.manager?.destroy(); + this.managerUnsubscribe?.(); + + delete this.manager; } }