Refine task editor layout and personal reminder defaults
This commit is contained in:
1 parent
8fd0b6ec8b
commit
a6bf3dfe41
14 files changed
+263
-26
No files matched your search
@@ -40,13 +40,16 @@ type TaskPreferences struct {
|
||||
ReviewDays *int `json:"review_days"`
|
||||
Estimate int `json:"estimate_minutes"`
|
||||
Complexity int `json:"complexity"`
|
||||
NotifyDue bool `json:"notify_due"`
|
||||
NotifyPlanned bool `json:"notify_planned"`
|
||||
ReminderTime string `json:"reminder_time"`
|
||||
DigestEnabled bool `json:"digest_enabled"`
|
||||
DigestTime string `json:"digest_time"`
|
||||
Timezone string `json:"timezone"`
|
||||
}
|
||||
|
||||
func (s *Store) TaskPreferences(ctx context.Context, domain, actor string) (TaskPreferences, error) {
|
||||
p := TaskPreferences{AssigneeUUID: actor, Complexity: 1, DigestTime: "09:00", Timezone: "UTC"}
|
||||
p := TaskPreferences{AssigneeUUID: actor, Complexity: 1, ReminderTime: "09:00", DigestTime: "09:00", Timezone: "UTC"}
|
||||
if err := taskActor(ctx, s.DB, domain, actor, false); err != nil {
|
||||
return p, err
|
||||
}
|
||||
@@ -86,6 +89,14 @@ func (s *Store) SaveTaskPreferences(ctx context.Context, domain, actor string, p
|
||||
if s.ReadOnly {
|
||||
return p, ErrReadOnly
|
||||
}
|
||||
// Older clients do not send this field. Preserve their default clock.
|
||||
if p.ReminderTime == "" {
|
||||
p.ReminderTime = "09:00"
|
||||
}
|
||||
clock, clockErr := time.Parse("15:04", p.ReminderTime)
|
||||
if clockErr != nil || clock.Format("15:04") != p.ReminderTime {
|
||||
return p, ErrTaskInvalid
|
||||
}
|
||||
for _, n := range []*int{p.DueDays, p.StartDays, p.PlannedDays, p.ReviewDays} {
|
||||
if n != nil && (*n < 0 || *n > 3650) {
|
||||
return p, ErrTaskInvalid
|
||||
|
||||
Reference in new issue
Block a user