Modify like functionality on web to stop redirect to new page#736
Modify like functionality on web to stop redirect to new page#736kesha-shah wants to merge 2 commits intokagisearch:mainfrom
Conversation
Intercept emoji-form submissions with fetch to /api/like (existing JSON endpoint) so the page no longer redirects on like. The like count updates in-place on the UI. A localStorage key per URL+emoji (with 7-day expiry) prevents repeat likes from the same browser. The server-side like() endpoint and /favorite alias are untouched so older clients, extensions, and JS-disabled browsers keep working via the original form-post-and-redirect flow. Made-with: Cursor
|
Hi @libhide @vprelovac Thanks for making smallweb App!! Apart from this fix for web, I also have some suggestions for the smallweb app as well, could you tell me what would be the right place to discuss those? Are github Issues okay? |
|
Thanks @kesha-shah! I think the like + navigate to next post UX was added intentially on web. Maybe @vprelovac can confirm? For the mobile app, that made less sense so we went a more native approach of allowing people to just like a post. re: mobile contribution: For now, feel free to open issues on this repo and tag me. That said, I would like to open source the Small Web mobile app soon. It is something we are aligning on internally at the moment. |
|
Thanks @libhide ! Also if I use this on mobile web (not mobile app), once I like and it redirects, there is no way to go back or search also so I generally end up losing those blogs before reading fully. |
|
On the web it is intentional as you caneasilly go back. And like serves as new post in this manner (this is why its so close to it). on mobile we should fix that going back works. |
|
Thanks @vprelovac for the response , yes I also checked that it has been introduced in march only but it was still confusing from user perspective as we generally do not expect to redirect anywhere while liking post. Feel free to close the PR if you feel this is not an issue! Thank you :D |
ktsirangelos
left a comment
There was a problem hiding this comment.
thanks for the suggestion @kesha-shah
if we were implementing that, i'd do it a bit differently, for example like increases the counter and like again decreases it (for the same "person") instead of disabling the button (and there are more details to consider)
since we are not merging, the bug you mentioned "going back and liking the same post multiple times from the same device" is real, i'll create a ticket to investigate and possibly fix ;)
Summary
On web, when a user likes any post, it instantly redirects to a new post which is
confusing - I'm just liking a post but haven't finished reading it. Also, the same
post can be liked again and again since there's no client-side storage. I verified
that the app already handles this correctly (likes without navigating away).
Changes
/api/like(existing JSON endpoint) instead of form-submittingto
/like, so it returns JSON without a page redirectthe button in-place
localStorage doesn't accumulate over time
Before
pre-like-fix.mp4
After
post-like-fix.mp4
Test plan