diff --git a/src/notifications/schedulers/ETANotificationScheduler.ts b/src/notifications/schedulers/ETANotificationScheduler.ts index 943b74d..98a16a2 100644 --- a/src/notifications/schedulers/ETANotificationScheduler.ts +++ b/src/notifications/schedulers/ETANotificationScheduler.ts @@ -18,8 +18,6 @@ export class ETANotificationScheduler { this.etaSubscriberCallback = this.etaSubscriberCallback.bind(this); this.sendEtaNotificationImmediately = this.sendEtaNotificationImmediately.bind(this); this.sendEtaNotificationImmediatelyIfSecondsRemainingBelowThreshold = this.sendEtaNotificationImmediatelyIfSecondsRemainingBelowThreshold.bind(this); - - this.shuttleRepository.subscribeToEtaUpdates(this.etaSubscriberCallback); } private async sendEtaNotificationImmediately(notificationData: ScheduledNotification): Promise { @@ -81,4 +79,13 @@ export class ETANotificationScheduler { return await this.sendEtaNotificationImmediately(notificationObject); } + + // The following is a workaround for the constructor being called twice + public startListeningForUpdates() { + this.shuttleRepository.subscribeToEtaUpdates(this.etaSubscriberCallback); + } + + public stopListeningForUpdates() { + this.shuttleRepository.subscribeToEtaUpdates(this.etaSubscriberCallback); + } }