add cancelNotificationIfExists implementation

This commit is contained in:
2025-02-03 23:48:53 -08:00
parent 403bec7c63
commit 629fe4dddd

View File

@@ -198,7 +198,18 @@ export class NotificationService {
* @param stopId Stop ID of the ETA object. * @param stopId Stop ID of the ETA object.
*/ */
public async cancelNotificationIfExists({ deviceId, shuttleId, stopId }: ScheduledNotificationData) { 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);
}
} }
/** /**