[PR #2031] [MERGED] fix(api): preserve IsFavorite for saved filters in ReadOne #8007

Closed
opened 2026-04-20 17:58:53 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2031
Author: @IAMSamuelRodda
Created: 12/28/2025
Status: Merged
Merged: 1/6/2026
Merged by: @kolaente

Base: mainHead: fix/saved-filter-favorite-persists


📝 Commits (1)

  • ac05ae7 fix(api): preserve IsFavorite for saved filters in ReadOne

📊 Changes

1 file changed (+8 additions, -3 deletions)

View changed files

📝 pkg/models/project.go (+8 -3)

📄 Description

Summary

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

Root Cause

Two issues in pkg/models/project.go ReadOne():

  1. IsFavorite wasn't being copied from the SavedFilter struct to the Project struct
  2. The isFavorite() lookup was then overwriting the value with false (since saved filters don't use the regular project favorites table)

Fix

  • Copy sf.IsFavorite to p.IsFavorite when loading a saved filter as a project
  • Skip the isFavorite() lookup for saved filters since they manage their favorite status independently via the saved_filters table

Test plan

  • Create/mark a saved filter as favorite (via API since no UI exists)
  • Refresh page - filter appears in both Favorites and Filters sections (intended)
  • Click on the filter to navigate to it
  • Verify filter still appears in Favorites section (before fix: it disappeared)
  • Verify /api/v1/projects/-{id} returns is_favorite: true matching /api/v1/filters/{id}

Fixes #1989

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/2031 **Author:** [@IAMSamuelRodda](https://github.com/IAMSamuelRodda) **Created:** 12/28/2025 **Status:** ✅ Merged **Merged:** 1/6/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `fix/saved-filter-favorite-persists` --- ### 📝 Commits (1) - [`ac05ae7`](https://github.com/go-vikunja/vikunja/commit/ac05ae77a89a496632c60f6204d09acf2279b379) fix(api): preserve IsFavorite for saved filters in ReadOne ### 📊 Changes **1 file changed** (+8 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `pkg/models/project.go` (+8 -3) </details> ### 📄 Description ## Summary - 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) ## Root Cause Two issues in `pkg/models/project.go` `ReadOne()`: 1. `IsFavorite` wasn't being copied from the `SavedFilter` struct to the `Project` struct 2. The `isFavorite()` lookup was then overwriting the value with `false` (since saved filters don't use the regular project favorites table) ## Fix - Copy `sf.IsFavorite` to `p.IsFavorite` when loading a saved filter as a project - Skip the `isFavorite()` lookup for saved filters since they manage their favorite status independently via the `saved_filters` table ## Test plan - [x] Create/mark a saved filter as favorite (via API since no UI exists) - [x] Refresh page - filter appears in both Favorites and Filters sections (intended) - [x] Click on the filter to navigate to it - [x] Verify filter still appears in Favorites section (before fix: it disappeared) - [x] Verify `/api/v1/projects/-{id}` returns `is_favorite: true` matching `/api/v1/filters/{id}` Fixes #1989 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 17:58:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#8007