Skip to content

Waves speed optimization - #3157

Merged
feruzm merged 1 commit into
developmentfrom
waves
Mar 28, 2026
Merged

Waves speed optimization#3157
feruzm merged 1 commit into
developmentfrom
waves

Conversation

@feruzm

@feruzm feruzm commented Mar 28, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added support for multiple waves feed types: "For You," "Following," and tag-based filtering.
  • Improvements

    • Redesigned tab navigation with modern pill-style appearance and improved visual feedback.
    • Enhanced scroll-to-top behavior with debounced visibility handling.
    • Optimized feed rendering performance through lazy loading.

@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The waves screen refactored its single-feed implementation into a reusable WavesFeed component, introducing multi-feed support via TabView for "for-you," "following," and "tag" filtering contexts. Updated tab styling to a pill-like design and added lazy mounting logic to optimize rendering performance.

Changes

Cohort / File(s) Summary
Waves Screen Refactoring
src/screens/waves/screen/wavesScreen.tsx
Extracted new WavesFeed component managing waves query, pagination, scroll handling, and deletion callbacks. Replaced single feed with TabView-driven multi-feed system (for-you/following/tag). Implemented separate list refs per feed type, lazy content mounting, and moved scroll-popup state logic into the feed component. Updated delete handling flow through onVisibilityChange.
Tab Styling Updates
src/screens/waves/styles/children.styles.ts
Refactored tab appearance from bottom-border style to pill-like bordered containers with horizontal padding, gap spacing, and centered content. Updated active/inactive tab styling for colors and background fill.
Screen Style Extensions
src/screens/waves/styles/wavesScreen.styles.ts
Added new style declarations: feedsContainer, tabScenesContainer, tabScene (all flex: 1), and listSpacing (padding: 32) to support new layout structure.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • #3156: Modifies the same wavesScreen.tsx with feed/tab/tag handling logic and relies on coordinated changes to useWavesQuery and WavesHeader integration.

Poem

🐰 Hops of joy through waves so fine,
Feeds now bloom in tabs aligned,
Pills of style in every row,
Lazy mounting steals the show!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Waves speed optimization' is vague and does not accurately reflect the actual changes, which involve a major architectural refactoring to introduce a reusable WavesFeed component with multi-feed support via TabView, not performance optimization. Revise the title to be more specific about the actual changes, such as 'Refactor WavesScreen with reusable WavesFeed component and multi-feed TabView' or 'Add multi-feed support and component extraction to WavesScreen'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch waves

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/screens/waves/screen/wavesScreen.tsx (1)

30-30: Use the src/ 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

📥 Commits

Reviewing files that changed from the base of the PR and between 046ed1f and f630959.

📒 Files selected for processing (3)
  • src/screens/waves/screen/wavesScreen.tsx
  • src/screens/waves/styles/children.styles.ts
  • src/screens/waves/styles/wavesScreen.styles.ts

}) => void;
isDarkTheme: boolean;
}) => {
const wavesQuery = wavesQueries.useWavesQuery(queryOptions, WAVES_HOST);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Comment on lines 218 to 220
if (tab === 'following' && !isLoggedIn) {
RootNavigation.navigate({ name: ROUTES.SCREENS.LOGIN });
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

@feruzm
feruzm merged commit e2b0979 into development Mar 28, 2026
2 checks passed
@feruzm
feruzm deleted the waves branch March 28, 2026 20:33
@coderabbitai coderabbitai Bot mentioned this pull request Mar 30, 2026
This was referenced May 20, 2026
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