diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 187df187d..ae3df859b 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -622,7 +622,7 @@ func getTaskReminderMap(s *xorm.Session, taskIDs []int64) (taskReminders map[int return } -func addRelatedTasksToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]*Task) (err error) { +func addRelatedTasksToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]*Task, a web.Auth) (err error) { relatedTasks := []*TaskRelation{} err = s.In("task_id", taskIDs).Find(&relatedTasks) if err != nil { @@ -645,10 +645,16 @@ func addRelatedTasksToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64] return } + taskFavorites, err := getFavorites(s, relatedTaskIDs, a, FavoriteKindTask) + if err != nil { + return err + } + // NOTE: while it certainly be possible to run this function on fullRelatedTasks again, we don't do this for performance reasons. // Go through all task relations and put them into the task objects for _, rt := range relatedTasks { + fullRelatedTasks[rt.OtherTaskID].IsFavorite = taskFavorites[rt.OtherTaskID] taskMap[rt.TaskID].RelatedTasks[rt.RelationKind] = append(taskMap[rt.TaskID].RelatedTasks[rt.RelationKind], fullRelatedTasks[rt.OtherTaskID]) } @@ -729,7 +735,7 @@ func addMoreInfoToTasks(s *xorm.Session, taskMap map[int64]*Task, a web.Auth) (e } // Get all related tasks - err = addRelatedTasksToTasks(s, taskIDs, taskMap) + err = addRelatedTasksToTasks(s, taskIDs, taskMap, a) return } diff --git a/pkg/models/unit_tests.go b/pkg/models/unit_tests.go index 51c034aa3..d3a0e7b22 100644 --- a/pkg/models/unit_tests.go +++ b/pkg/models/unit_tests.go @@ -60,6 +60,7 @@ func SetupTests() { "buckets", "saved_filters", "subscriptions", + "favorites", ) if err != nil { log.Fatal(err)