From 5451ddf58d8a7380a3a7f3448b297313379cef67 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 16 Mar 2024 12:35:22 +0100 Subject: [PATCH] fix(views): return tasks directly or in buckets, no matter if accessing via user or link share --- pkg/models/task_collection.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pkg/models/task_collection.go b/pkg/models/task_collection.go index 3573c5dc45..95e5ad5d76 100644 --- a/pkg/models/task_collection.go +++ b/pkg/models/task_collection.go @@ -117,6 +117,17 @@ func getTaskFilterOptsFromCollection(tf *TaskCollection, projectView *ProjectVie return opts, err } +func getTaskOrTasksInBuckets(s *xorm.Session, a web.Auth, projects []*Project, view *ProjectView, opts *taskSearchOptions) (tasks interface{}, resultCount int, totalItems int64, err error) { + if view != nil { + if view.BucketConfigurationMode != BucketConfigurationModeNone { + tasksInBuckets, err := GetTasksInBucketsForView(s, view, opts, a) + return tasksInBuckets, len(tasksInBuckets), int64(len(tasksInBuckets)), err + } + } + + return getTasksForProjects(s, projects, a, opts, view) +} + // ReadAll gets all tasks for a collection // @Summary Get tasks in a project // @Description Returns all tasks for the current project. @@ -213,7 +224,7 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa if err != nil { return nil, 0, 0, err } - return getTasksForProjects(s, []*Project{project}, a, opts, view) + return getTaskOrTasksInBuckets(s, a, []*Project{project}, view, opts) } // If the project ID is not set, we get all tasks for the user. @@ -246,12 +257,5 @@ func (tf *TaskCollection) ReadAll(s *xorm.Session, a web.Auth, search string, pa projects = []*Project{{ID: tf.ProjectID}} } - if view != nil { - if view.BucketConfigurationMode != BucketConfigurationModeNone { - tasksInBuckets, err := GetTasksInBucketsForView(s, view, opts, a) - return tasksInBuckets, len(tasksInBuckets), int64(len(tasksInBuckets)), err - } - } - - return getTasksForProjects(s, projects, a, opts, view) + return getTaskOrTasksInBuckets(s, a, projects, view, opts) }