Skip to content

Commit

Permalink
enh: set later today to 6pm
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Aug 9, 2023
1 parent 86db2d7 commit 9d43583
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
12 changes: 9 additions & 3 deletions apps/files_reminders/src/components/SetReminderActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`,
Expand All @@ -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[]
},
},
Expand Down
21 changes: 11 additions & 10 deletions apps/files_reminders/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@ 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]: () => {
const day = moment()
.add(1, 'day')
.startOf('day')
.add(8, 'hour')
.toDate()
return day
return day.toDate()
},

[DateTimePreset.ThisWeekend]: () => {
Expand Down Expand Up @@ -80,8 +82,7 @@ export const getDateTime = (dateTime: DateTimePreset): Date => {
.startOf('isoWeek')
.add(1, 'week')
.add(8, 'hour')
.toDate()
return day
return day.toDate()
},
}

Expand Down

0 comments on commit 9d43583

Please sign in to comment.