Skip to content

Modify like functionality on web to stop redirect to new page#736

Open
kesha-shah wants to merge 2 commits intokagisearch:mainfrom
kesha-shah:feat/modify-like-web-functionality
Open

Modify like functionality on web to stop redirect to new page#736
kesha-shah wants to merge 2 commits intokagisearch:mainfrom
kesha-shah:feat/modify-like-web-functionality

Conversation

@kesha-shah
Copy link
Copy Markdown
Contributor

@kesha-shah kesha-shah commented Apr 15, 2026

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

  1. From FE, now calls /api/like (existing JSON endpoint) instead of form-submitting
    to /like, so it returns JSON without a page redirect
  2. Updated FE code to handle the JSON response and show the increased like count on
    the button in-place
  3. Disabled users from liking the same post again by storing likes in localStorage
  4. Added a daily sweep to remove localStorage entries older than 7 days, so
    localStorage doesn't accumulate over time

Before

pre-like-fix.mp4

After

post-like-fix.mp4

Test plan

  • Click an emoji on a post — page should NOT redirect; count should increment
  • Reload the page — the same emoji button should appear dimmed/disabled
  • Test with localStorage unavailable (private browsing) — liking should still work

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
@kesha-shah kesha-shah marked this pull request as ready for review April 15, 2026 10:16
@kesha-shah
Copy link
Copy Markdown
Contributor Author

kesha-shah commented Apr 15, 2026

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?
I would like to contribute on app as well but seems like the code is not open sourced for the same :)

@libhide
Copy link
Copy Markdown
Collaborator

libhide commented Apr 15, 2026

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.

@kesha-shah
Copy link
Copy Markdown
Contributor Author

Thanks @libhide !
Yes from code it looks like redirection after like has been added intentionally in March functionality as well but somehow its super confusing for me and few other people I checked with. Because we just expect it to like the post and not redirect it.

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.

@vprelovac
Copy link
Copy Markdown
Contributor

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.

@kesha-shah
Copy link
Copy Markdown
Contributor Author

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.
In that case, is it possible to not like same post multiple times? Currently I can keep increasing like counts for the same post from same device.

Feel free to close the PR if you feel this is not an issue!

Thank you :D

Copy link
Copy Markdown
Collaborator

@ktsirangelos ktsirangelos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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.

4 participants