mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-24 22:25:15 +00:00
fix(filters): preserve IsFavorite for saved filters in ReadOne (#2031)
- Saved filters' `IsFavorite` field was not being properly returned when
fetched as pseudo-projects via `/projects/{id}`
- This caused favorited filters to appear in both the Favorites and
Filters sections initially, but then disappear from Favorites after
clicking on them (navigating to the filter)
Fixes #1989
Co-authored-by: iamsamuelrodda <iamsamuelrodda@users.noreply.github.com>
This commit is contained in:
@@ -295,6 +295,7 @@ func (p *Project) ReadOne(s *xorm.Session, a web.Auth) (err error) {
|
||||
}
|
||||
p.Title = sf.Title
|
||||
p.Description = sf.Description
|
||||
p.IsFavorite = sf.IsFavorite
|
||||
p.Created = sf.Created
|
||||
p.Updated = sf.Updated
|
||||
p.OwnerID = sf.OwnerID
|
||||
@@ -334,9 +335,13 @@ func (p *Project) ReadOne(s *xorm.Session, a web.Auth) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
p.IsFavorite, err = isFavorite(s, p.ID, a, FavoriteKindProject)
|
||||
if err != nil {
|
||||
return
|
||||
// For saved filters, IsFavorite was already set from the SavedFilter struct.
|
||||
// Don't overwrite it with the project favorites lookup.
|
||||
if !isFilter {
|
||||
p.IsFavorite, err = isFavorite(s, p.ID, a, FavoriteKindProject)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
subs, err := GetSubscriptionForUser(s, SubscriptionEntityProject, p.ID, a)
|
||||
|
||||
Reference in New Issue
Block a user