Make sure list / task favorites are set per user, not per entity #915

Merged
konrad merged 15 commits from fix/favorites into main 2021-07-10 10:21:54 +00:00
2 changed files with 9 additions and 2 deletions
Showing only changes of commit 783bda514f - Show all commits

View File

@ -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
}

View File

@ -60,6 +60,7 @@ func SetupTests() {
"buckets",
"saved_filters",
"subscriptions",
"favorites",
)
if err != nil {
log.Fatal(err)