From f08f16a5f33c80798f1f2fdfa724caadac0b2aa6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 29 Jul 2022 13:59:25 +0200 Subject: [PATCH 1/2] Add file-picker display hint --- config/option.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/option.go b/config/option.go index 84166f1..7337145 100644 --- a/config/option.go +++ b/config/option.go @@ -158,11 +158,14 @@ const ( // only sense together with the PossibleValues property // of Option. DisplayHintOneOf = "one-of" - // DisplayHintOrdered Used to mark a list option as ordered. + // DisplayHintOrdered is used to mark a list option as ordered. // That is, the order of items is important and a user interface // is encouraged to provide the user with re-ordering support // (like drag'n'drop). DisplayHintOrdered = "ordered" + // DisplayHintFilePicker is used to mark the option as being a file, which + // should give the option to use a file picker to select a local file from disk. + DisplayHintFilePicker = "file-picker" ) // Option describes a configuration option. From b001302cb2ebb3a97de3242ccaeed2be976f4c9d Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 29 Jul 2022 13:59:57 +0200 Subject: [PATCH 2/2] Add options to disable task repeating and schedule --- modules/tasks.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/tasks.go b/modules/tasks.go index b7b35f6..cf09caf 100644 --- a/modules/tasks.go +++ b/modules/tasks.go @@ -201,26 +201,37 @@ func (t *Task) MaxDelay(maxDelay time.Duration) *Task { return t } -// Schedule schedules the task for execution at the given time. +// Schedule schedules the task for execution at the given time. A zero time will remove cancel the scheduled execution. func (t *Task) Schedule(executeAt time.Time) *Task { t.lock.Lock() defer t.lock.Unlock() t.executeAt = executeAt - t.addToSchedule(false) + + if executeAt.IsZero() { + t.removeFromQueues() + } else { + t.addToSchedule(false) + } return t } -// Repeat sets the task to be executed in endless repeat at the specified interval. First execution will be after interval. Minimum repeat interval is one minute. +// Repeat sets the task to be executed in endless repeat at the specified interval. First execution will be after interval. Minimum repeat interval is one minute. An interval of zero will disable repeating, but won't change the current schedule. func (t *Task) Repeat(interval time.Duration) *Task { // check minimum interval duration - if interval < minRepeatDuration { + if interval != 0 && interval < minRepeatDuration { interval = minRepeatDuration } t.lock.Lock() defer t.lock.Unlock() + // Check if repeating should be disabled. + if interval == 0 { + t.repeat = 0 + return t + } + t.repeat = interval t.executeAt = time.Now().Add(t.repeat) t.addToSchedule(false)