Skip to content

Add favourites feature with filtering and toggle functionality#171

Merged
yogeshpaliyal merged 7 commits intomasterfrom
copilot/add-favourites-tab-and-option
Oct 10, 2025
Merged

Add favourites feature with filtering and toggle functionality#171
yogeshpaliyal merged 7 commits intomasterfrom
copilot/add-favourites-tab-and-option

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 10, 2025

Overview

This PR implements a complete favourites feature for Deepr, allowing users to mark links as favourites and filter them separately. This addresses #[issue_number] which requested adding favourites functionality to the app.

Changes Made

Database Layer

  • Added isFavourite column to the Deepr table (INTEGER, default 0)
  • Implemented toggleFavourite SQL query to toggle favourite status using a CASE statement
  • Implemented setFavourite SQL query for explicit favourite status setting
  • Updated getLinksAndTags query to include the isFavourite field and support filtering by favourite status
  • Created migration file 4.sqm to ensure smooth upgrades for existing users

ViewModel Layer

  • Added favouriteFilter StateFlow to track the current filter state (-1 = All, 1 = Favourites)
  • Implemented setFavouriteFilter(filter: Int) method to update the filter
  • Implemented toggleFavourite(id: Long) method to toggle favourite status
  • Enhanced the accounts query to combine favourite filtering with existing search, sort, and tag filters

UI Layer

  • Home Screen: Added FilterChip tabs below the search bar displaying "All" and "Favourites" options
  • DeeprItem: Added a new dropdown menu item to toggle favourite status
    • Shows "Add to favourites" with Star icon when not marked as favourite
    • Shows "Remove from favourites" with StarFilled icon when marked as favourite
    • Menu item position: after "Show QR Code" and before "Edit"

Localization

  • Added three new string resources: favourites, add_to_favourites, and remove_from_favourites

How It Works

Users can now:

  1. Tap the three-dot menu on any link and select "Add to favourites" to mark it
  2. Use the "All" and "Favourites" tabs below the search bar to filter their links
  3. Remove links from favourites via the same menu option (which dynamically changes to "Remove from favourites")

The favourite status persists across app restarts and integrates seamlessly with existing search, sort, and tag filtering capabilities.

Technical Details

  • Filtering happens at the SQL level for optimal performance
  • The implementation uses -1 to indicate "show all" in the SQL WHERE clause: ? = -1 OR Deepr.isFavourite = ?
  • UI updates reactively through StateFlow when favourite status changes
  • The feature is fully backward compatible with existing data through the migration file

Files Changed

  • app/src/main/sqldelight/com/yogeshpaliyal/deepr/Deepr.sq - Schema and queries
  • app/src/main/sqldelight/migrations/4.sqm - Database migration (new file)
  • app/src/main/java/com/yogeshpaliyal/deepr/viewmodel/AccountViewModel.kt - Filter logic
  • app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/home/Home.kt - Filter tabs UI
  • app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/home/DeeprItem.kt - Toggle menu item
  • app/src/main/res/values/strings.xml - String resources

Total Changes: +111 lines, -7 lines across 6 files

Testing Notes

The implementation follows all existing architectural patterns in the codebase. Manual testing should verify:

  • Marking/unmarking links as favourites
  • Filtering between All and Favourites tabs
  • Persistence across app restarts
  • Interaction with existing search and tag filters
  • Database migration from version 3 to 4

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/agents/gradle-instrumentation-agent-8.13.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.13 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add favourites</issue_title>
<issue_description>- Add a tab for All/Favourites on top below search bar.

  • Add column of is favourite in Deepr Table.
  • Add Option in to add and remove favourites.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #170


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 10, 2025 03:07
Co-authored-by: yogeshpaliyal <9381846+yogeshpaliyal@users.noreply.github.com>
Co-authored-by: yogeshpaliyal <9381846+yogeshpaliyal@users.noreply.github.com>
Copilot AI changed the title [WIP] Add favourites feature with toggle option Add favourites feature with filtering and toggle functionality Oct 10, 2025
Copilot AI requested a review from yogeshpaliyal October 10, 2025 03:14
@yogeshpaliyal yogeshpaliyal marked this pull request as ready for review October 10, 2025 07:09
@yogeshpaliyal yogeshpaliyal merged commit ec66367 into master Oct 10, 2025
1 check passed
@yogeshpaliyal yogeshpaliyal deleted the copilot/add-favourites-tab-and-option branch October 10, 2025 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add favourites

2 participants