2 KiB
2 KiB
Feed Reactions Fix - Implementation Summary
Status: COMPLETE & DEPLOYED ✅
1. Issue Description
- Problem: Reactions were not displaying on the "Following" (Home) and "Profile" feeds. The "Postcard" UI (specifically the compact method) was defaulting to the "Add Reaction" button because no reaction data was being returned by the API for these lists.
- Root Cause: The SQL queries for
GetFeedandGetPostsByAuthorin the backend were not aggregating reaction data (counts and user choices), unlike the single-post endpoint.
2. Implementation Details (Backend)
- File:
internal/repository/post_repository.go - Changes:
- Modified
GetFeedSQL query to include a correlated subquery fetchingjsonb_object_agg(emoji, count)forreaction_counts. - Modified
GetPostsByAuthorSQL query to do the same. - Added logic to fetch
my_reactions(the current user's votes) for both feeds. - Updated the Go
Scandestinations to populate theReactionsandMyReactionsfields in thePostmodel. - Correction: Also fixed a missing
allow_chainandvisibilityselection in theGetPostsByAuthorquery, ensuring consistency across the app.
- Modified
3. Frontend logic (Verified)
- Widget:
sojornPostCard->PostActions->ReactionsDisplay - Logic: The
ReactionsDisplaywidget incompactmode (used in feeds) is designed to:- Show the user's reaction if they voted.
- Else, show the "Most Used" reaction from the community.
- Else (if valid data but count is 0), show the "Add" button.
- Result: Now that the backend provides the data (Case 1 or 2), the UI will correctly display the reaction chips instead of just the "+" button.
4. Deployment
- Server:
194.238.28.122 - Action:
- Compiled
sojorn-api-linuxlocally. - Uploaded to
/opt/sojorn/bin/apiviascp(user:patrick). - Restarted
sojorn-apiservice viasystemctl.
- Compiled
- Status: API is active and serving the new queries.
5. Next Steps
- User Action: Pull-to-refresh the feed in the Sojorn app to see the changes.