Skip to content

Commit

Permalink
Update onResume to only refresh screen when on the HomePage
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgxvii committed Jan 9, 2025
1 parent 6942339 commit b9a4d74
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/app/pages/home/containers/home-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ export class HomePageComponent implements OnInit, OnDestroy {
private platform: Platform,
private usage: UsageService
) {
this.resumeListener = this.platform.resume.subscribe(() => this.onResume())
this.changeDetectionListener =
this.tasksService.changeDetectionEmitter.subscribe(() => {
console.log('Changes to task service detected')
console.log('Changes to task service detected..')
this.navCtrl.navigateRoot('')
})
}
Expand Down Expand Up @@ -89,7 +88,10 @@ export class HomePageComponent implements OnInit, OnDestroy {
}

ngOnDestroy() {
this.resumeListener.unsubscribe()
// Unsubscribe to avoid memory leaks when the page is left
if (this.resumeListener) {
this.resumeListener.unsubscribe();
}
this.changeDetectionListener.unsubscribe()
}

Expand All @@ -100,6 +102,14 @@ export class HomePageComponent implements OnInit, OnDestroy {
this.sortedTasks = this.tasksService.getValidTasksMap()
this.tasks = this.tasksService.getTasksOfToday()
this.showCalendar = false
this.resumeListener = this.platform.resume.subscribe(() => this.onResume())
}

ionViewWillLeave() {
// Unsubscribe to avoid memory leaks when the page is left
if (this.resumeListener) {
this.resumeListener.unsubscribe();
}
}

init() {
Expand Down Expand Up @@ -198,7 +208,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
buttons: [
{
text: this.localization.translateKey(LocKeys.BTN_OKAY),
handler: () => {}
handler: () => { }
}
]
})
Expand All @@ -216,7 +226,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
buttons: [
{
text: this.localization.translateKey(LocKeys.BTN_OKAY),
handler: () => {}
handler: () => { }
}
]
})
Expand Down

0 comments on commit b9a4d74

Please sign in to comment.