diff --git a/src/notifications/schedulers/ETANotificationScheduler.ts b/src/notifications/schedulers/ETANotificationScheduler.ts index 76c6027..4e0227a 100644 --- a/src/notifications/schedulers/ETANotificationScheduler.ts +++ b/src/notifications/schedulers/ETANotificationScheduler.ts @@ -75,12 +75,13 @@ export class ETANotificationScheduler { private async etaSubscriberCallback(eta: IEta) { const tuple = new TupleKey(eta.shuttleId, eta.stopId); - if (this.deviceIdsToDeliverTo[tuple.toString()] === undefined) { + const tupleKey = tuple.toString(); + if (this.deviceIdsToDeliverTo[tupleKey] === undefined) { return; } const deviceIdsToRemove = new Set(); - for (let deviceId of Object.keys(this.deviceIdsToDeliverTo[tuple.toString()])) { + for (let deviceId of Object.keys(this.deviceIdsToDeliverTo[tupleKey])) { const deliveredSuccessfully = await this.sendEtaNotificationImmediatelyIfSecondsRemainingBelowThreshold(deviceId, eta); if (deliveredSuccessfully) { deviceIdsToRemove.add(deviceId); @@ -88,7 +89,7 @@ export class ETANotificationScheduler { } deviceIdsToRemove.forEach((deviceId) => { - delete this.deviceIdsToDeliverTo[tuple.toString()][deviceId] + delete this.deviceIdsToDeliverTo[tupleKey][deviceId] }); }