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:
Samuel Rodda
2026-01-07 01:47:17 +10:30
committed by GitHub
parent 51d76ea2e2
commit 3a47c062da

View File

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