Skip to content

fix: Add optimistic cache updates for tweet deletion and user actions - #189

Merged
salehahmed99 merged 3 commits into
devfrom
fix/Media-and-search-caching
Dec 16, 2025
Merged

fix: Add optimistic cache updates for tweet deletion and user actions#189
salehahmed99 merged 3 commits into
devfrom
fix/Media-and-search-caching

Conversation

@AbdallahAyman03

Copy link
Copy Markdown
Collaborator

Summary

This PR includes multiple fixes for cache invalidation and UI improvements.

Changes

🔄 Delete Mutation Cache Updates (useTweetActions.ts)

  • Added optimistic cache updates for searchPosts, explore, categoryPosts, and tweet-quotes when deleting tweets
  • Added cache invalidation in onSuccess and onError handlers
  • Created new remove functions in cacheUtils.ts:
    • removeTweetFromSearchPostsCache
    • removeTweetFromExploreCache
    • removeTweetFromCategoryPostsCache
    • removeTweetFromQuotesCache

👥 Search Users Cache on Follow/Block (useFollowUser.ts, useBlockUser.ts)

  • Added ISearchUsersMappedPageData type to search types
  • Follow/unfollow now updates search users cache immediately
  • Block/unblock now removes users from search results cache
  • Added cache invalidation on error

📹 Video Duration Placeholder (useMediaViewerControls.ts, MediaViewerModal.tsx)

  • Shows --:-- for invalid time values (NaN, Infinity, negative)
  • Shows --:-- for duration until video metadata loads (duration > 0)

🔧 MediaViewerModal iOS Fix (MediaViewerModal.tsx)

  • Moved CreatePostModal inside the main Modal component
  • Fixes reply/quote modal not opening on iPhone

Testing

  • Tested delete mutation updates search/explore/quotes lists
  • Tested follow/unfollow updates search users list
  • Tested block removes user from search results
  • Tested video duration shows placeholder until loaded

…s, and display placeholder for invalid media viewer time.
@salehahmed99
salehahmed99 merged commit bb97c32 into dev Dec 16, 2025
1 check passed
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