diff --git a/src/repositories/InMemoryNotificationRepository.ts b/src/repositories/InMemoryNotificationRepository.ts index bd1db3f..513f7b7 100644 --- a/src/repositories/InMemoryNotificationRepository.ts +++ b/src/repositories/InMemoryNotificationRepository.ts @@ -107,6 +107,12 @@ export class InMemoryNotificationRepository implements NotificationRepository { const secondsThreshold = this.deviceIdsToDeliverTo[tupleKey.toString()][deviceId]; delete this.deviceIdsToDeliverTo[tupleKey.toString()][deviceId]; + + if (Object.keys(this.deviceIdsToDeliverTo[tupleKey.toString()]).length === 0) { + // no more device IDs remaining for this key combination + delete this.deviceIdsToDeliverTo[tupleKey.toString()]; + } + this.listeners.forEach((listener) => { const event: NotificationEvent = { event: 'delete',