Skip to content

Commit

Permalink
fix(task/item): new tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
helmecke committed Oct 11, 2023
1 parent 1f3dd8c commit 6ba0775
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions internal/task/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,21 @@ type Item struct {
// NewTask is creating a new task
func NewTask(mod *parser.Modification) *Item {
task := &Item{
UUID: uuid.New(),
Description: mod.Description,
// Due: filter.Due,
// Tags: filter.Tags,
UUID: uuid.New(),
Status: statusPending,
Created: time.Now(),
}

task.Modify(mod, false)

return task
}

// Modify modifies task with given modification
func (i *Item) Modify(mod *parser.Modification) {
i.Modified = time.Now()
func (i *Item) Modify(mod *parser.Modification, modified bool) {
if modified {
i.Modified = time.Now()
}

if mod.HasDescription() {
i.Description = mod.Description
Expand Down
2 changes: 1 addition & 1 deletion internal/taskgopher/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (a *App) ModifyTask(filter *parser.Filter, mod *parser.Modification) error
a.TaskList.Filter(filter)

for _, task := range a.TaskList.Filtered() {
task.Modify(mod)
task.Modify(mod, true)

a.TaskList.Set(task)
fmt.Printf("Modified task %d.\n", task.ID)
Expand Down

0 comments on commit 6ba0775

Please sign in to comment.