Skip to content

feat: make who to follow updates optimistic - #930

Closed
WendellAdriel wants to merge 2 commits into
dev-null-sh:productionfrom
WendellAdriel:feat/optimistic-suggested-follows
Closed

WendellAdriel wants to merge 2 commits into
dev-null-sh:productionfrom
WendellAdriel:feat/optimistic-suggested-follows

Conversation

@WendellAdriel

Copy link
Copy Markdown
Contributor

Following or unfollowing someone in Who to follow waited for the server before updating the icon. It now updates immediately through Inertia's optimistic updates and rolls back if the request fails. Repeat clicks for the same person are blocked while the request is pending.

@WendellAdriel
WendellAdriel marked this pull request as ready for review October 21, 2026 19:28
@WendellAdriel WendellAdriel changed the title Make Who to follow updates optimistic feat: make who to follow updates optimistic Oct 21, 2026
@jubianchi

Copy link
Copy Markdown
Contributor

Hey @WendellAdriel, I noticed that the behaviour this PR describes may already be on production, through 4751a40 (Nov 1, on top of #573). In resources/js/components/follow-button.tsx, useFollow():

  • flips the follow state in onStart, before the server answers
  • rolls it back in onCancel, onNetworkError and onHttpException
  • blocks repeat clicks with onBefore: () => !isPending

FollowIconButton, used by Who to follow, spreads those callbacks on its link, so suggestions update immediately. It goes through shared follow state rather than Inertia's optimistic option, which also covers previews and notifications. tests/Unit/FollowState.test.tsx has cases for the blocked second click and the rollback.

As far as I can tell, what this PR adds is covered there.

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.

2 participants