@@ -4,9 +4,12 @@ import { StorageParams } from '../storage/storage-params';
44import { DAY_MINUTES , SECOND , getNextTimeOfDay } from '../utils/time' ;
55import { Settings } from '../compositions/settings' ;
66import { dailySummaryNotification } from './daily-summary-notification' ;
7+ import { removeOldTimeIntervals } from './remove-time-intervals' ;
8+ import { startOfTomorrow } from 'date-fns' ;
79
810export enum JobId {
911 DailySummaryNotification = '@alarm/daily-summary-notification' ,
12+ RemoveOldTimeIntervals = '@alarm/remove-old-time-intervals' ,
1013}
1114
1215export function scheduleJobs ( ) : void {
@@ -17,6 +20,10 @@ export function scheduleJobs(): void {
1720 await dailySummaryNotification ( ) ;
1821 break ;
1922 }
23+ case JobId . RemoveOldTimeIntervals : {
24+ await removeOldTimeIntervals ( ) ;
25+ break ;
26+ }
2027 }
2128 log ( `[schedule-jobs] ${ alarm . name } finished` ) ;
2229 } ) ;
@@ -34,6 +41,11 @@ export async function rescheduleJobs(): Promise<void> {
3441 when : getNextTimeOfDay ( dailySummaryNotificationTime * SECOND ) ,
3542 periodInMinutes : DAY_MINUTES ,
3643 } ) ;
44+
45+ await createAlarmIfMissing ( JobId . RemoveOldTimeIntervals , {
46+ when : startOfTomorrow ( ) . getTime ( ) ,
47+ periodInMinutes : DAY_MINUTES ,
48+ } ) ;
3749}
3850
3951async function createAlarmIfMissing (
0 commit comments