Skip to content

Closes #1203 - #1416

Open
mansur-codes wants to merge 3 commits into
Epta-Node:mainfrom
mansur-codes:fix/issue-1203-optimistic-like-reconciliation
Open

Closes #1203#1416
mansur-codes wants to merge 3 commits into
Epta-Node:mainfrom
mansur-codes:fix/issue-1203-optimistic-like-reconciliation

Conversation

@mansur-codes

Copy link
Copy Markdown
Contributor

Summary

Fixes an issue where an optimistic like written to OptimisticStore was never reconciled when a feed refetch (e.g. switching to a "following-only" filter) removed the target post from the visible set, or when the server confirmed a different state for that post. This allowed stale "liked" state to resurrect on a later refetch or tab switch.

Added a reconcileFeed(userAddress, visiblePosts) method to OptimisticStore (apps/web/src/lib/optimisticStore.ts) that, on every feed refresh, deletes optimistic like/tip entries belonging to the current user for posts that are either no longer visible (filtered out) or now present in the fresh server response (server wins, since deletion causes the relevant hook to fall back to initialState, which reflects server truth). Entries for other users are left untouched.

Wired OptimisticStore.reconcileFeed() into apps/web/src/app/feed/page.tsx at the three points where fresh posts are set: after fetchExploreFeed, after fetchFollowingFeed (with results), and after the empty-following-list case.

Deviation note: the original issue listed apps/web/src/components/Feed.tsx as a file to modify. On investigation, Feed.tsx is a purely presentational component with no interaction with OptimisticStore or the fetch lifecycle — all relevant logic lives in feed/page.tsx. Feed.tsx was left unmodified; feed/page.tsx was substituted as the correct fix location.

Known gap for follow-up: the new unit tests in optimisticStore.test.ts pass standalone via npx jest, but apps-web currently has no "test" script wired into the turbo pipeline, so pnpm test at the monorepo root does not yet execute them. This is a pre-existing gap unrelated to this fix — flagging for visibility.

Type of Change

  • Bug fix
  • New feature
  • Contract change (logic, storage, or API)
  • Documentation update
  • Refactor / chore

Testing Done

  • cargo test passes (not applicable — this is a TypeScript/web change)
  • New tests added for changed behaviour
  • Manually verified on Testnet (if applicable)
  • Database migration tested (if applicable)
  • TypeScript SDK tests passed (if applicable)

Added apps/web/src/lib/optimisticStore.test.ts covering: filtered-out post pruned, server-wins-for-present-post, tip state pruned (absent and present cases), cross-user entries left untouched, and listener notification. All 6 pass via npx jest src/lib/optimisticStore.test.ts. pnpm typecheck, pnpm build, and pnpm lint pass for apps-web specifically; monorepo-wide failures in linkora-sdk and contracts are pre-existing and unrelated to files touched here (confirmed by grepping tsc output for optimisticStore/feed/page with zero matches).

Checklist

  • Changes are focused — one concern per PR
  • If a contract function was added or changed, the README API table is updated (not applicable — no contract changes)
  • No unresolved merge conflicts
  • No secrets or private keys committed

Related Issue

Closes #1203

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@mansur-codes Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@mansur-codes is attempting to deploy a commit to the Jaja's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Web: Optimistic like in feed is not rolled back when the same post is unfollow-filtered on refetch

1 participant