Waves speed optimization - #3157
Conversation
📝 WalkthroughWalkthroughThe waves screen refactored its single-feed implementation into a reusable Changes
Sequence Diagram(s)sequenceDiagram
participant WavesScreen
participant TabView
participant WavesFeed as WavesFeed (for-you)
participant WavesFeed2 as WavesFeed (following)
participant WavesFeed3 as WavesFeed (tag)
participant WavesQuery
User->>WavesScreen: Select feed tab
WavesScreen->>TabView: onIndexChange (feedType)
TabView->>WavesFeed: Render active scene
WavesFeed->>WavesQuery: useWavesQuery(queryOptions)
WavesQuery-->>WavesFeed: waves data
WavesFeed->>WavesFeed: FlatList with pagination
User->>WavesFeed: Scroll list
WavesFeed->>WavesScreen: onScrollStateChange (show/hide scroll-to-top)
User->>WavesFeed: Delete wave
WavesFeed->>WavesQuery: deleteWave via onVisibilityChange
WavesQuery-->>WavesFeed: Updated data
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/screens/waves/screen/wavesScreen.tsx (1)
30-30: Use thesrc/alias for the new header import.This refactor adds a new deep relative path even though the repo standard is absolute imports from
src/.♻️ Suggested change
-import { WavesHeader, WavesFeedType } from '../children/wavesHeader'; +import { WavesHeader, WavesFeedType } from 'src/screens/waves/children/wavesHeader';As per coding guidelines, "Use
src/as base URL for absolute imports in TypeScript".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/screens/waves/screen/wavesScreen.tsx` at line 30, Change the relative import for WavesHeader and WavesFeedType to use the project absolute import alias (src/) instead of a deep relative path; in wavesScreen.tsx replace the import that pulls WavesHeader and WavesFeedType from '../children/wavesHeader' with an absolute import from 'src/screens/waves/children/wavesHeader' so the symbols WavesHeader and WavesFeedType follow the repo's src/ import convention.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/screens/waves/screen/wavesScreen.tsx`:
- Around line 218-220: The guard that navigates to login when tab ===
'following' && !isLoggedIn returns early and leaves the screen blank if auth is
lost; after calling RootNavigation.navigate({ name: ROUTES.SCREENS.LOGIN }) also
set the active feed state to the public fallback (e.g., setTab('for-you') or
setFeedType('for-you')) so the UI renders the "for-you" feed instead of an empty
scene; apply the same change to the other occurrence around the feed/auth check
at the later block (the one at lines ~288-291) so both places fall back to
'for-you' after redirecting to login.
- Line 72: The delete logic in wavesQuery (used via wavesQueries.useWavesQuery
and invoked by WavesFeed) only mutates the current sdkQueryOptions.queryKey,
leaving the same wave in other mounted feed variants; update the deleteWave
handler to fan the cache update across all wave-feed queries (or call
queryClient.invalidateQueries for the common wave-feed query key/prefix) after a
successful delete so every WavesFeed instance removes the item; locate the
mutation in deleteWave in wavesQueries and either iterate over matching
queryClient.getQueriesData keys to remove the wave from each cache entry or call
invalidateQueries for the shared wave-feed key pattern to ensure all feeds
reflect the deletion.
---
Nitpick comments:
In `@src/screens/waves/screen/wavesScreen.tsx`:
- Line 30: Change the relative import for WavesHeader and WavesFeedType to use
the project absolute import alias (src/) instead of a deep relative path; in
wavesScreen.tsx replace the import that pulls WavesHeader and WavesFeedType from
'../children/wavesHeader' with an absolute import from
'src/screens/waves/children/wavesHeader' so the symbols WavesHeader and
WavesFeedType follow the repo's src/ import convention.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 558cd684-4534-4a2e-aaaa-d1edf993fc5f
📒 Files selected for processing (3)
src/screens/waves/screen/wavesScreen.tsxsrc/screens/waves/styles/children.styles.tssrc/screens/waves/styles/wavesScreen.styles.ts
| }) => void; | ||
| isDarkTheme: boolean; | ||
| }) => { | ||
| const wavesQuery = wavesQueries.useWavesQuery(queryOptions, WAVES_HOST); |
There was a problem hiding this comment.
Deleting a wave here will leave stale entries in the other feeds.
WavesFeed is now instantiated for separate feed contexts, but wavesQuery.deleteWave only updates the current query instance. In src/providers/queries/postQueries/wavesQueries.ts:91-124, the mutation prunes only sdkQueryOptions.queryKey, so deleting from one mounted feed can leave the same wave visible in the others until the next refetch. Please fan that cache update out to the other wave queries, or invalidate all wave-feed variants after a successful delete.
Also applies to: 125-136
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/screens/waves/screen/wavesScreen.tsx` at line 72, The delete logic in
wavesQuery (used via wavesQueries.useWavesQuery and invoked by WavesFeed) only
mutates the current sdkQueryOptions.queryKey, leaving the same wave in other
mounted feed variants; update the deleteWave handler to fan the cache update
across all wave-feed queries (or call queryClient.invalidateQueries for the
common wave-feed query key/prefix) after a successful delete so every WavesFeed
instance removes the item; locate the mutation in deleteWave in wavesQueries and
either iterate over matching queryClient.getQueriesData keys to remove the wave
from each cache entry or call invalidateQueries for the shared wave-feed key
pattern to ensure all feeds reflect the deletion.
| if (tab === 'following' && !isLoggedIn) { | ||
| RootNavigation.navigate({ name: ROUTES.SCREENS.LOGIN }); | ||
| return; |
There was a problem hiding this comment.
Don't strand the user on a blank following tab after logout.
The login gate only runs on direct tab taps. If auth is lost while feedType === 'following', this branch returns an empty scene and the screen stays blank instead of falling back to for-you.
💡 Suggested fallback
+ useEffect(() => {
+ if (!isLoggedIn && feedType === 'following') {
+ setEnableScrollTop(false);
+ setFeedType('for-you');
+ }
+ }, [feedType, isLoggedIn]);
+
const _handleTabChange = (tab: WavesFeedType) => {
if (tab === 'following' && !isLoggedIn) {
RootNavigation.navigate({ name: ROUTES.SCREENS.LOGIN });
return;
}Also applies to: 288-291
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/screens/waves/screen/wavesScreen.tsx` around lines 218 - 220, The guard
that navigates to login when tab === 'following' && !isLoggedIn returns early
and leaves the screen blank if auth is lost; after calling
RootNavigation.navigate({ name: ROUTES.SCREENS.LOGIN }) also set the active feed
state to the public fallback (e.g., setTab('for-you') or setFeedType('for-you'))
so the UI renders the "for-you" feed instead of an empty scene; apply the same
change to the other occurrence around the feed/auth check at the later block
(the one at lines ~288-291) so both places fall back to 'for-you' after
redirecting to login.
Summary by CodeRabbit
New Features
Improvements