diff --git a/src/services/NotificationService.ts b/src/services/NotificationService.ts index 1b49710..a59d31e 100644 --- a/src/services/NotificationService.ts +++ b/src/services/NotificationService.ts @@ -198,7 +198,18 @@ export class NotificationService { * @param stopId Stop ID of the ETA object. */ public async cancelNotificationIfExists({ deviceId, shuttleId, stopId }: ScheduledNotificationData) { + const tupleKey = new TupleKey(shuttleId, stopId); + if ( + this.deviceIdsToDeliverTo[tupleKey.toString()] === undefined + || !this.deviceIdsToDeliverTo[tupleKey.toString()].includes(deviceId) + ) { + return; + } + const index = this.deviceIdsToDeliverTo[tupleKey.toString()].findIndex(id => id === deviceId); + if (index !== -1) { + this.deviceIdsToDeliverTo[tupleKey.toString()].splice(index, 1); + } } /**