diff --git a/modules/todoist/display.go b/modules/todoist/display.go index 8ceac803..35fffd1f 100644 --- a/modules/todoist/display.go +++ b/modules/todoist/display.go @@ -14,6 +14,10 @@ func (widget *Widget) content() (string, string, bool) { return widget.CommonSettings().Title, "", false } + if proj.err != nil { + return widget.CommonSettings().Title, proj.err.Error(), true + } + title := fmt.Sprintf("[green]%s[white]", proj.Project.Name) str := "" diff --git a/modules/todoist/project.go b/modules/todoist/project.go index b3e39808..bff2e088 100644 --- a/modules/todoist/project.go +++ b/modules/todoist/project.go @@ -11,21 +11,22 @@ type Project struct { index int tasks []todoist.Task + err error } func NewProject(id int) *Project { // Todoist seems to experience a lot of network issues on their side // If we can't connect, handle it with an empty project until we can project, err := todoist.GetProject(id) - if err != nil { - return &Project{} - } - proj := &Project{ - Project: project, - index: -1, } + if err != nil { + proj.err = err + return proj + } + + proj.Project = project proj.loadTasks() @@ -38,7 +39,11 @@ func (proj *Project) isLast() bool { func (proj *Project) loadTasks() { tasks, err := todoist.ListTask(todoist.QueryParam{"project_id": fmt.Sprintf("%d", proj.ID)}) - if err == nil { + if err != nil { + proj.err = err + proj.tasks = nil + } else { + proj.err = nil proj.tasks = tasks } }