From 9c22e154be54f49e53da77d7253f4be9142eec28 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Thu, 27 Mar 2025 11:34:01 -0700 Subject: [PATCH] add bindings for the notifications repository --- src/repositories/InMemoryNotificationRepository.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/repositories/InMemoryNotificationRepository.ts b/src/repositories/InMemoryNotificationRepository.ts index d93af1f..bd1db3f 100644 --- a/src/repositories/InMemoryNotificationRepository.ts +++ b/src/repositories/InMemoryNotificationRepository.ts @@ -21,6 +21,16 @@ export class InMemoryNotificationRepository implements NotificationRepository { private listeners: Listener[] = []; + constructor() { + this.getAllNotificationsForShuttleAndStopId = this.getAllNotificationsForShuttleAndStopId.bind(this); + this.getSecondsThresholdForNotificationIfExists = this.getSecondsThresholdForNotificationIfExists.bind(this); + this.deleteNotificationIfExists = this.deleteNotificationIfExists.bind(this); + this.addOrUpdateNotification = this.addOrUpdateNotification.bind(this); + this.isNotificationScheduled = this.isNotificationScheduled.bind(this); + this.subscribeToNotificationChanges = this.subscribeToNotificationChanges.bind(this); + this.unsubscribeFromNotificationChanges = this.unsubscribeFromNotificationChanges.bind(this); + } + async getAllNotificationsForShuttleAndStopId(shuttleId: string, stopId: string) { const tuple = new TupleKey(shuttleId, stopId); if (this.deviceIdsToDeliverTo[tuple.toString()] === undefined) { @@ -51,7 +61,8 @@ export class InMemoryNotificationRepository implements NotificationRepository { } async isNotificationScheduled(lookupArguments: NotificationLookupArguments): Promise { - return await this.getSecondsThresholdForNotificationIfExists(lookupArguments) !== null; + const threshold = await this.getSecondsThresholdForNotificationIfExists(lookupArguments); + return threshold !== null; } async addOrUpdateNotification({