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
var listIDs []int64
var hasFavoriteLists bool
var hasFavoritesList bool
for _, l := range lists {
if l.ID == FavoritesPseudoList.ID {
hasFavoriteLists = true
hasFavoritesList = true
continue
}
listIDs = append(listIDs, l.ID)
}
@ -375,7 +376,7 @@ func getRawTasksForLists(s *xorm.Session, lists []*List, a web.Auth, opts *taskO
listCond = listIDCond
}
if hasFavoriteLists {
if hasFavoritesList {
// Make sure users can only see their favorites
userLists, _, _, err := getRawListsForUser(
s,
@ -393,16 +394,17 @@ func getRawTasksForLists(s *xorm.Session, lists []*List, a web.Auth, opts *taskO
userListIDs = append(userListIDs, l.ID)
}
favs, err := getFavorites(s, userListIDs, a, FavoriteKindList)
if err != nil {
return nil, 0, 0, err
}
var favoriteListIDs []int64
for id, _ := range favs {
favoriteListIDs = append(favoriteListIDs, id)
}
// All favorite tasks for that user
favCond := builder.
Select("entity_id").
From("favorites").
Where(
builder.And(
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 {