Skip to content

Commit

Permalink
Merge pull request #39798 from nextcloud/enh/reminder-options
Browse files Browse the repository at this point in the history
enh(files_reminders): Adjust reminder options
  • Loading branch information
AndyScherzinger authored Aug 10, 2023
2 parents a38a86e + 23a581d commit f2353a6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
39 changes: 19 additions & 20 deletions apps/files_reminders/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const getDateTime = (dateTime: DateTimePreset): null | Date => {
const evening = moment()
.startOf('day')
.add(18, 'hour')
if (now.isSameOrAfter(evening)) {
const cutoff = evening
.clone()
.subtract(1, 'hour')
if (now.isSameOrAfter(cutoff)) {
return null
}
return evening.toDate()
Expand All @@ -53,36 +56,32 @@ export const getDateTime = (dateTime: DateTimePreset): null | Date => {

[DateTimePreset.ThisWeekend]: () => {
const today = moment()
if (
[
5, // Friday
6, // Saturday
7, // Sunday
].includes(today.isoWeekday())
) {
return null
}
const saturday = moment()
.startOf('isoWeek')
.add(5, 'day')
.add(8, 'hour')
const sunday = moment()
.startOf('isoWeek')
.add(6, 'day')
.add(8, 'hour')
if (today.isSame(saturday, 'date')) {
return saturday
.add(1, 'day')
.toDate()
}
if (today.isSame(sunday, 'date')) {
return sunday
.add(1, 'week')
.startOf('isoWeek')
.add(5, 'day')
.add(8, 'hour')
.toDate()
}
return saturday.toDate()
},

[DateTimePreset.NextWeek]: () => {
const day = moment()
const today = moment()
if (today.isoWeekday() === 7) { // Sunday
return null
}
const workday = moment()
.startOf('isoWeek')
.add(1, 'week')
.add(8, 'hour')
return day.toDate()
return workday.toDate()
},
}

Expand Down
4 changes: 2 additions & 2 deletions dist/files_reminders-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_reminders-main.js.map

Large diffs are not rendered by default.

0 comments on commit f2353a6

Please sign in to comment.