Skip to content

Commit e90bb86

Browse files
committed
Migrate to v2 of the todoist api
IDs are strings, fixing a lot of the previous problems Relies on wtfutil/todoist#4
1 parent 3273ae0 commit e90bb86

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ require (
5151
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
5252
github.com/stretchr/testify v1.8.1
5353
github.com/wtfutil/spotigopher v0.0.0-20191127141047-7d8168fe103a
54-
github.com/wtfutil/todoist v0.0.2-0.20191216004217-0ec29ceda61a
54+
github.com/wtfutil/todoist v0.0.3
5555
github.com/xanzy/go-gitlab v0.77.0
5656
github.com/zmb3/spotify v0.0.0-20191010212056-e12fb981aacb
5757
github.com/zorkian/go-datadog-api v2.30.0+incompatible

modules/todo_plus/backend/todoist.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package backend
22

33
import (
4-
"strconv"
4+
"fmt"
55

66
"github.com/olebedev/config"
77
"github.com/wtfutil/todoist"
@@ -24,7 +24,7 @@ func (todo *Todoist) BuildProjects() []*Project {
2424
projects := []*Project{}
2525

2626
for _, id := range todo.projects {
27-
i := strconv.Itoa(id.(int))
27+
i := fmt.Sprintf("%v", id)
2828
proj := todo.GetProject(i)
2929
projects = append(projects, proj)
3030
}
@@ -38,15 +38,13 @@ func (todo *Todoist) GetProject(id string) *Project {
3838
Index: -1,
3939
backend: todo,
4040
}
41-
i64, _ := strconv.ParseUint(id, 10, 32)
42-
i := uint(i64)
43-
project, err := todoist.GetProject(i)
41+
project, err := todoist.GetProject(id)
4442
if err != nil {
4543
proj.Err = err
4644
return proj
4745
}
4846

49-
proj.ID = strconv.FormatUint(uint64(project.ID), 10)
47+
proj.ID = project.ID
5048
proj.Name = project.Name
5149

5250
tasks, err := todo.LoadTasks(proj.ID)
@@ -57,9 +55,8 @@ func (todo *Todoist) GetProject(id string) *Project {
5755
}
5856

5957
func toTask(task todoist.Task) Task {
60-
id := strconv.FormatUint(uint64(task.ID), 10)
6158
return Task{
62-
ID: id,
59+
ID: task.ID,
6360
Completed: task.Completed,
6461
Name: task.Content,
6562
}
@@ -80,19 +77,15 @@ func (todo *Todoist) LoadTasks(id string) ([]Task, error) {
8077

8178
func (todo *Todoist) CloseTask(task *Task) error {
8279
if task != nil {
83-
i64, _ := strconv.ParseUint(task.ID, 10, 32)
84-
i := uint(i64)
85-
internal := todoist.Task{ID: i}
80+
internal := todoist.Task{ID: task.ID}
8681
return internal.Close()
8782
}
8883
return nil
8984
}
9085

9186
func (todo *Todoist) DeleteTask(task *Task) error {
9287
if task != nil {
93-
i64, _ := strconv.ParseUint(task.ID, 10, 32)
94-
i := uint(i64)
95-
internal := todoist.Task{ID: i}
88+
internal := todoist.Task{ID: task.ID}
9689
return internal.Delete()
9790
}
9891
return nil
@@ -101,7 +94,7 @@ func (todo *Todoist) DeleteTask(task *Task) error {
10194
func (todo *Todoist) Sources() []string {
10295
var result []string
10396
for _, id := range todo.projects {
104-
i := strconv.Itoa(id.(int))
97+
i := fmt.Sprintf("%v", id)
10598
result = append(result, i)
10699
}
107100
return result

0 commit comments

Comments
 (0)