fix: partial fix to allow list tasks in ios reminders app (#2717)
This PR introduces a partial fix for the CalDAV task listing bug (#753) when handling PROPFIND requests with `Depth: 1`, improving task visibility in the iOS Reminders app. Notes: * This might make Thunderbird somewhat usable when interacting with tasks using the `/dav/projects/{id} url`. * This does not fully resolve the issue where the Reminders app will only display the last project after some time when adding the URL. This is my first time working with Golang and CalDAV, so I’d really appreciate any feedback or suggestions on the code structure, style, or any improvements I could make. Co-authored-by: JD <43763092+jdw1023@users.noreply.github.com> Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2717 Reviewed-by: konrad <k@knt.li> Co-authored-by: jd <jd@noreply.kolaente.dev> Co-committed-by: jd <jd@noreply.kolaente.dev> (cherry picked from commit 84dbc5fd8467418be6390f4fe9eee9abdc50bf45)
This commit is contained in:
parent
e318e604b5
commit
60fa211334
@ -52,7 +52,7 @@ type VikunjaCaldavProjectStorage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetResources returns either all projects, links to the principal, or only one project, depending on the request
|
// GetResources returns either all projects, links to the principal, or only one project, depending on the request
|
||||||
func (vcls *VikunjaCaldavProjectStorage) GetResources(rpath string, _ bool) ([]data.Resource, error) {
|
func (vcls *VikunjaCaldavProjectStorage) GetResources(rpath string, withChildren bool) ([]data.Resource, error) {
|
||||||
|
|
||||||
// It looks like we need to have the same handler for returning both the calendar home set and the user principal
|
// It looks like we need to have the same handler for returning both the calendar home set and the user principal
|
||||||
// Since the client seems to ignore the whatever is being returned in the first request and just makes a second one
|
// Since the client seems to ignore the whatever is being returned in the first request and just makes a second one
|
||||||
@ -92,6 +92,24 @@ func (vcls *VikunjaCaldavProjectStorage) GetResources(rpath string, _ bool) ([]d
|
|||||||
}
|
}
|
||||||
r := data.NewResource(rpath, &rr)
|
r := data.NewResource(rpath, &rr)
|
||||||
r.Name = vcls.project.Title
|
r.Name = vcls.project.Title
|
||||||
|
|
||||||
|
// If the request is withChildren (Depth: 1), we need to return all tasks of the project
|
||||||
|
if withChildren {
|
||||||
|
resources := []data.Resource{r}
|
||||||
|
|
||||||
|
// Check if there are tasks to iterate over
|
||||||
|
if vcls.project.Tasks != nil {
|
||||||
|
for i := range vcls.project.Tasks {
|
||||||
|
taskResource := VikunjaProjectResourceAdapter{
|
||||||
|
project: vcls.project,
|
||||||
|
task: &vcls.project.Tasks[i].Task,
|
||||||
|
isCollection: false,
|
||||||
|
}
|
||||||
|
addTaskResource(&vcls.project.Tasks[i].Task, &taskResource, &resources)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resources, nil
|
||||||
|
}
|
||||||
return []data.Resource{r}, nil
|
return []data.Resource{r}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,9 +181,7 @@ func (vcls *VikunjaCaldavProjectStorage) GetResourcesByList(rpaths []string) (re
|
|||||||
rr := VikunjaProjectResourceAdapter{
|
rr := VikunjaProjectResourceAdapter{
|
||||||
task: t,
|
task: t,
|
||||||
}
|
}
|
||||||
r := data.NewResource(getTaskURL(t), &rr)
|
addTaskResource(t, &rr, &resources)
|
||||||
r.Name = t.Title
|
|
||||||
resources = append(resources, r)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -671,3 +687,9 @@ func (vcls *VikunjaCaldavProjectStorage) getProjectRessource(isCollection bool)
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addTaskResource(task *models.Task, rr *VikunjaProjectResourceAdapter, resources *[]data.Resource) {
|
||||||
|
taskResourceInstance := data.NewResource(getTaskURL(task), rr)
|
||||||
|
taskResourceInstance.Name = task.Title
|
||||||
|
*resources = append(*resources, taskResourceInstance)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user