Fix explore page showing Install for already enabled apps#4665
Fix explore page showing Install for already enabled apps#4665
Conversation
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of incorrect 'enabled' status for apps on the explore page by fetching the user's enabled apps directly from the server. The introduction of the new /v1/apps/enabled endpoint on the backend and the getEnabledAppsServer function on the client is a clean solution. Using Future.wait to fetch app data and enabled status in parallel is a good performance optimization.
My main feedback is regarding code duplication in app/lib/providers/app_provider.dart. The logic for fetching and processing apps is repeated in both getApps and refreshAppsAfterChange methods. I've left a comment suggesting to refactor this into a shared private method to improve maintainability.
Overall, this is a solid improvement that fixes a user-facing bug and improves the data consistency of the app.
Summary
v2/appsendpoint) returnsenabled: falsefor all apps because it uses a globally cached response with no per-user state_syncEnabledStateFromCache()from local SharedPreferences, but this was unreliable (stale on fresh install, cache clear, or new device)GET /v1/apps/enabledendpoint that returns the user's enabled app IDs from Redis (SMEMBERS— single cheap call)v2/appsand setsenabledfrom the server response_syncEnabledStateFromCache()workaroundTest plan
🤖 Generated with Claude Code