fetch tasks for caldav lists #641
|
@ -317,8 +317,9 @@ func (vcls *VikunjaCaldavListStorage) DeleteResource(rpath string) error {
|
|||
|
||||
// VikunjaListResourceAdapter holds the actual resource
|
||||
type VikunjaListResourceAdapter struct {
|
||||
list *models.List
|
||||
task *models.Task
|
||||
list *models.List
|
||||
listTasks []*models.Task
|
||||
task *models.Task
|
||||
|
||||
isPrincipal bool
|
||||
isCollection bool
|
||||
|
@ -354,12 +355,12 @@ func (vlra *VikunjaListResourceAdapter) CalculateEtag() string {
|
|||
// GetContent returns the content string of a resource (a task in our case)
|
||||
func (vlra *VikunjaListResourceAdapter) GetContent() string {
|
||||
if vlra.list != nil && vlra.list.Tasks != nil {
|
||||
return getCaldavTodosForTasks(vlra.list)
|
||||
return getCaldavTodosForTasks(vlra.list, vlra.listTasks)
|
||||
}
|
||||
|
||||
if vlra.task != nil {
|
||||
list := models.List{Tasks: []*models.Task{vlra.task}}
|
||||
return getCaldavTodosForTasks(&list)
|
||||
return getCaldavTodosForTasks(&list, list.Tasks)
|
||||
}
|
||||
|
||||
return ""
|
||||
|
@ -397,8 +398,27 @@ func (vcls *VikunjaCaldavListStorage) getListRessource(isCollection bool) (rr Vi
|
|||
return
|
||||
}
|
||||
|
||||
listTasks := vcls.list.Tasks
|
||||
if listTasks == nil {
|
||||
tk := models.TaskCollection{
|
||||
ListID: vcls.list.ID,
|
||||
}
|
||||
iface, _, _, err := tk.ReadAll(vcls.user, "", 1, 1000)
|
||||
if err != nil {
|
||||
return rr, err
|
||||
}
|
||||
tasks, ok := iface.([]*models.Task)
|
||||
if !ok {
|
||||
panic("Tasks returned from TaskCollection.ReadAll are not []*models.Task!")
|
||||
konrad marked this conversation as resolved
Outdated
|
||||
}
|
||||
|
||||
listTasks = tasks
|
||||
vcls.list.Tasks = tasks
|
||||
}
|
||||
|
||||
rr = VikunjaListResourceAdapter{
|
||||
list: vcls.list,
|
||||
listTasks: listTasks,
|
||||
isCollection: isCollection,
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ import (
|
|||
"github.com/laurent22/ical-go"
|
||||
)
|
||||
|
||||
func getCaldavTodosForTasks(list *models.List) string {
|
||||
func getCaldavTodosForTasks(list *models.List, listTasks []*models.Task) string {
|
||||
|
||||
// Make caldav todos from Vikunja todos
|
||||
var caldavtodos []*caldav.Todo
|
||||
for _, t := range list.Tasks {
|
||||
for _, t := range listTasks {
|
||||
|
||||
duration := t.EndDate.Sub(t.StartDate)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
By design, this should always be true, if it isn't something is wrong with the implementation. Could you add a
panic
in that case? (In anelse
) That way it would be catched in the tests if it fails.Done.