Make pseudo list of favorite tasks work again

This commit is contained in:
kolaente 2021-07-09 22:54:27 +02:00
parent e13aa067ef
commit d06ee82769
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 14 additions and 12 deletions

View File

@ -252,10 +252,11 @@ func getRawTasksForLists(s *xorm.Session, lists []*List, a web.Auth, opts *taskO
// Get all list IDs and get the tasks // Get all list IDs and get the tasks
var listIDs []int64 var listIDs []int64
var hasFavoriteLists bool var hasFavoritesList bool
for _, l := range lists { for _, l := range lists {
if l.ID == FavoritesPseudoList.ID { if l.ID == FavoritesPseudoList.ID {
hasFavoriteLists = true hasFavoritesList = true
continue
} }
listIDs = append(listIDs, l.ID) listIDs = append(listIDs, l.ID)
} }
@ -375,7 +376,7 @@ func getRawTasksForLists(s *xorm.Session, lists []*List, a web.Auth, opts *taskO
listCond = listIDCond listCond = listIDCond
} }
if hasFavoriteLists { if hasFavoritesList {
// Make sure users can only see their favorites // Make sure users can only see their favorites
userLists, _, _, err := getRawListsForUser( userLists, _, _, err := getRawListsForUser(
s, s,
@ -393,16 +394,17 @@ func getRawTasksForLists(s *xorm.Session, lists []*List, a web.Auth, opts *taskO
userListIDs = append(userListIDs, l.ID) userListIDs = append(userListIDs, l.ID)
} }
favs, err := getFavorites(s, userListIDs, a, FavoriteKindList) // All favorite tasks for that user
if err != nil { favCond := builder.
return nil, 0, 0, err Select("entity_id").
} From("favorites").
var favoriteListIDs []int64 Where(
for id, _ := range favs { builder.And(
favoriteListIDs = append(favoriteListIDs, id) builder.Eq{"user_id": a.GetID()},
} builder.Eq{"kind": FavoriteKindTask},
))
listCond = builder.Or(listIDCond, builder.In("list_id", favoriteListIDs)) listCond = builder.And(listCond, builder.And(builder.In("id", favCond), builder.In("list_id", userListIDs)))
} }
if len(reminderFilters) > 0 { if len(reminderFilters) > 0 {