]> source.dussan.org Git - nextcloud-server.git/commitdiff
enh: set later today to 6pm
authorChristopher Ng <chrng8@gmail.com>
Wed, 9 Aug 2023 17:38:49 +0000 (10:38 -0700)
committerChristopher Ng <chrng8@gmail.com>
Wed, 9 Aug 2023 17:41:18 +0000 (10:41 -0700)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/files_reminders/src/components/SetReminderActions.vue
apps/files_reminders/src/shared/utils.ts

index d705f309ea03f5a1da0abd05b569be98e9853cb5..bf0b417a35502d5af4fed39e2e86013c9be2074f 100644 (file)
@@ -191,8 +191,11 @@ export default Vue.extend({
                },
 
                options(): ReminderOption[] {
-                       const computeOption = (option: ReminderOption) => {
+                       const computeOption = (option: ReminderOption): null | ReminderOption => {
                                const dateTime = getDateTime(option.dateTimePreset)
+                               if (!dateTime) {
+                                       return null
+                               }
                                return {
                                        ...option,
                                        ariaLabel: `${option.ariaLabel} – ${getVerboseDateString(dateTime)}`,
@@ -201,12 +204,15 @@ export default Vue.extend({
                                }
                        }
 
-                       return [
+                       const options = [
                                laterToday,
                                tomorrow,
                                thisWeekend,
                                nextWeek,
-                       ].map(computeOption)
+                       ]
+                       return options
+                               .map(computeOption)
+                               .filter(Boolean) as ReminderOption[]
                },
        },
 
index 5d223fe657d278e45e46c0ba31eaddf7111d66be..453e94e76d9daf27db0b7f418170e38f2129c587 100644 (file)
@@ -30,14 +30,17 @@ export enum DateTimePreset {
        NextWeek,
 }
 
-export const getDateTime = (dateTime: DateTimePreset): Date => {
-       const matchPreset: Record<DateTimePreset, () => Date> = {
+export const getDateTime = (dateTime: DateTimePreset): null | Date => {
+       const matchPreset: Record<DateTimePreset, () => null | Date> = {
                [DateTimePreset.LaterToday]: () => {
-                       const hour = moment().get('hour')
-                       const later = moment()
+                       const now = moment()
+                       const evening = moment()
                                .startOf('day')
-                               .add(hour + 3, 'hour')
-                       return later.toDate()
+                               .add(18, 'hour')
+                       if (now.isSameOrAfter(evening)) {
+                               return null
+                       }
+                       return evening.toDate()
                },
 
                [DateTimePreset.Tomorrow]: () => {
@@ -45,8 +48,7 @@ export const getDateTime = (dateTime: DateTimePreset): Date => {
                                .add(1, 'day')
                                .startOf('day')
                                .add(8, 'hour')
-                               .toDate()
-                       return day
+                       return day.toDate()
                },
 
                [DateTimePreset.ThisWeekend]: () => {
@@ -80,8 +82,7 @@ export const getDateTime = (dateTime: DateTimePreset): Date => {
                                .startOf('isoWeek')
                                .add(1, 'week')
                                .add(8, 'hour')
-                               .toDate()
-                       return day
+                       return day.toDate()
                },
        }