aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2023-08-09 10:38:49 -0700
committerChristopher Ng <chrng8@gmail.com>2023-08-09 10:41:18 -0700
commit9d43583b473d72aad1ce0912ec8c42204f99db89 (patch)
treebca3dbc373075660d53f652277c4e856009d6c53
parent86db2d7f15f8507e9c563507491b7dba3c63e932 (diff)
downloadnextcloud-server-9d43583b473d72aad1ce0912ec8c42204f99db89.tar.gz
nextcloud-server-9d43583b473d72aad1ce0912ec8c42204f99db89.zip
enh: set later today to 6pm
Signed-off-by: Christopher Ng <chrng8@gmail.com>
-rw-r--r--apps/files_reminders/src/components/SetReminderActions.vue12
-rw-r--r--apps/files_reminders/src/shared/utils.ts21
2 files changed, 20 insertions, 13 deletions
diff --git a/apps/files_reminders/src/components/SetReminderActions.vue b/apps/files_reminders/src/components/SetReminderActions.vue
index d705f309ea0..bf0b417a355 100644
--- a/apps/files_reminders/src/components/SetReminderActions.vue
+++ b/apps/files_reminders/src/components/SetReminderActions.vue
@@ -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[]
},
},
diff --git a/apps/files_reminders/src/shared/utils.ts b/apps/files_reminders/src/shared/utils.ts
index 5d223fe657d..453e94e76d9 100644
--- a/apps/files_reminders/src/shared/utils.ts
+++ b/apps/files_reminders/src/shared/utils.ts
@@ -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()
},
}