mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 16:00:32 +00:00
add cancelNotificationIfExists implementation
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user