Skip to content

fix(users): invalidate recommended stream cache on follow#1625

Draft
infin1t3 wants to merge 3 commits intodevfrom
fix/1224-who-to-follow-refresh-issue
Draft

fix(users): invalidate recommended stream cache on follow#1625
infin1t3 wants to merge 3 commits intodevfrom
fix/1224-who-to-follow-refresh-issue

Conversation

@infin1t3
Copy link
Copy Markdown
Collaborator

@infin1t3 infin1t3 commented Apr 1, 2026

Clear the recommended:all:all user stream from IndexedDB when a user is followed so the Who to Follow card shows fresh suggestions on next mount.

Made-with: Cursor

infin1t3 added 2 commits April 1, 2026 20:21
Clear the recommended:all:all user stream from IndexedDB when a user
is followed so the Who to Follow card shows fresh suggestions on next
mount.

Made-with: Cursor
@infin1t3
Copy link
Copy Markdown
Collaborator Author

infin1t3 commented Apr 1, 2026

@greptileai review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 1, 2026

Greptile Summary

This PR adds a targeted cache invalidation for the recommended:all:all user stream (Core.UserStreamTypes.RECOMMENDED) in IndexedDB whenever a follow action is performed. The fix ensures the "Who to Follow" card shows fresh suggestions on the next mount instead of re-displaying users the viewer has just followed.

  • The change is minimal and well-scoped: four lines inside updateUserStreams, guarded by isFollowing === true, pushed into the existing ops array and executed via Promise.all alongside other stream operations.
  • The correct service method (LocalStreamUsersService.deleteById) and enum constant (UserStreamTypes.RECOMMENDED = 'recommended:all:all') are used consistently with the rest of the codebase.
  • The approach mirrors the existing timeline stream invalidation pattern (invalidateTimelineStreams) already present in the same method.
  • No layer boundary violations: both LocalFollowService and LocalStreamUsersService live in the services/local layer, and services calling sibling local services is already the established pattern here (e.g. LocalStreamPostsService.deleteById in invalidateTimelineStreams).

Confidence Score: 5/5

  • Safe to merge — the change is minimal, correct, and consistent with existing cache-invalidation patterns.
  • No P0 or P1 issues found. The four-line addition uses the correct service, the correct enum constant, runs in the established Promise.all ops array, and mirrors the existing timeline stream invalidation pattern. No layer boundary violations, no dead code, no linter suppressions.
  • No files require special attention.

Important Files Changed

Filename Overview
src/core/services/local/follow/follow.ts Adds four-line cache invalidation for the recommended:all:all user stream when a follow action is performed, ensuring fresh suggestions on next mount of the Who to Follow card.

Sequence Diagram

sequenceDiagram
    participant UI as UI / Controller
    participant LFS as LocalFollowService
    participant LSUS as LocalStreamUsersService
    participant LSPS as LocalStreamPostsService
    participant IDB as IndexedDB

    UI->>LFS: create({ follower, followee, activeStreamId })
    LFS->>IDB: transaction(rw) — update connections, counts, relationships
    IDB-->>LFS: committed
    LFS->>LFS: updateUserStreams({ isFollowing: true, ... })
    par Follow stream ops
        LFS->>LSUS: prependToStream(follower:following, [followee])
        LFS->>LSUS: prependToStream(followee:followers, [follower])
        LFS->>LSUS: deleteById("recommended:all:all")  ← new
        LFS->>LSPS: deleteById(timelineStreamId)
    end
    LSUS->>IDB: delete "recommended:all:all" cache
    LSPS->>IDB: delete timeline stream cache
    IDB-->>LFS: done
    LFS-->>UI: resolved
    Note over UI,IDB: Next mount of Who to Follow card<br/>finds no cache → fetches fresh from Nexus
Loading

Reviews (1): Last reviewed commit: "Merge branch 'dev' into fix/1224-who-to-..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

🚀 Preview Deployment

URL: https://franky-preview-pr-1625-fzxmjul7ya-oa.a.run.app

franky-preview-pr-1625523b7d3

The sidebar WhoToFollow component stays mounted across route changes
(layout). In production (no React Strict Mode), the cache invalidation
on follow needs an explicit refetch trigger when the pathname changes.

Made-with: Cursor
@infin1t3 infin1t3 force-pushed the fix/1224-who-to-follow-refresh-issue branch from ba090e4 to 523b7d3 Compare April 1, 2026 18:43
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.

1 participant