From fb58414ba3955c33d47c1a13937d07e230e2a47e Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Thu, 27 Mar 2025 10:20:25 -0700 Subject: [PATCH] add notification repository as optional dependency --- .../schedulers/ETANotificationScheduler.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/notifications/schedulers/ETANotificationScheduler.ts b/src/notifications/schedulers/ETANotificationScheduler.ts index 385d350..0f875af 100644 --- a/src/notifications/schedulers/ETANotificationScheduler.ts +++ b/src/notifications/schedulers/ETANotificationScheduler.ts @@ -2,15 +2,22 @@ import { ShuttleGetterRepository } from "../../repositories/ShuttleGetterReposit import { TupleKey } from "../../types/TupleKey"; import { IEta } from "../../entities/entities"; import { AppleNotificationSender, NotificationAlertArguments } from "../senders/AppleNotificationSender"; -import { NotificationLookupArguments, ScheduledNotification } from "../../repositories/NotificationRepository"; +import { + NotificationLookupArguments, + NotificationRepository, + ScheduledNotification +} from "../../repositories/NotificationRepository"; +import { InMemoryNotificationRepository } from "../../repositories/InMemoryNotificationRepository"; type DeviceIdSecondsThresholdAssociation = { [key: string]: number }; export class ETANotificationScheduler { public static readonly defaultSecondsThresholdForNotificationToFire = 180; - constructor(private shuttleRepository: ShuttleGetterRepository, - private appleNotificationSender = new AppleNotificationSender() + constructor( + private shuttleRepository: ShuttleGetterRepository, + private notificationRepository: NotificationRepository = new InMemoryNotificationRepository(), + private appleNotificationSender = new AppleNotificationSender() ) { this.etaSubscriberCallback = this.etaSubscriberCallback.bind(this); this.sendEtaNotificationImmediately = this.sendEtaNotificationImmediately.bind(this);