Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: new arch #631

Merged
merged 16 commits into from
Nov 11, 2024
Merged

fix: new arch #631

merged 16 commits into from
Nov 11, 2024

Conversation

lovegaoshi
Copy link
Owner

@lovegaoshi lovegaoshi commented Nov 8, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced error handling for service binding in the widget.
    • Updated UI for album art in the widget with improved bitmap scaling.
    • Introduced new navigation theme management in the AzusaPlayer component.
    • Added support for customized drawer styling in navigation.
    • Implemented a new navigation structure for improved route handling across components.
  • Bug Fixes

    • Improved navigation logic across various components for consistency.
    • Adjusted karaoke color properties in the lyric display for better visibility.
  • Documentation

    • Updated comments in the code for clarity on theme handling and navigation logic.
  • Chores

    • Streamlined project setup by removing unnecessary modules and updating dependencies.
    • General maintenance to keep dependencies current and improve performance.

Copy link

vercel bot commented Nov 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
azusa-player-mobile ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2024 2:51pm

Copy link

coderabbitai bot commented Nov 8, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request includes significant updates across various components of a React Native application. Key changes involve enhancing error handling and UI logic in APMWidget.kt, modifying project configuration in settings.gradle, and updating dependencies in package.json. Additionally, several components have been adjusted to improve navigation handling, streamline theme management, and refine visual elements. Notably, the navigation logic has shifted to use an object format for route parameters, impacting how screens are navigated within the app. Overall, the changes focus on improving user experience and code maintainability.

Changes

File Path Change Summary
android/app/src/main/java/com/noxplay/noxplayer/APMWidget.kt Enhanced error handling, modified service binding logic, adjusted widget UI updates, and refined user interaction logic.
android/settings.gradle Updated project configuration, removed :react-native-code-push module, added useExpoModules() function.
package.json Updated scripts and incremented dependency versions for various packages, reflecting general maintenance.
patches/react-native-paper+5.12.5.patch Modified ProgressBar component to round the now property in accessibilityValue.
patches/react-native-screens+4.0.0.patch Introduced new constants and methods in Screen class, updated animation handling in ScreenStack.
patches/react-native-tab-view+3.5.2.patch Updated TabBar rendering logic to include a unique key prop for TabBarItem.
src/AzusaPlayer.tsx Added navigation theme management and updated drawer styling.
src/components/landscape/AzusaPlayerLandscape.tsx Introduced navigation theme management based on darkTheme property.
src/components/player/Lyric.tsx Adjusted karaoke color properties for improved visual representation.
src/components/playlists/View.tsx Updated navigation handling to use an object format and added new style definitions.
src/hooks/useSetupPlayer.ts Enhanced player initialization and loading processes, adjusting intent handling logic.
src/stores/initializeStores.ts Removed call to NoxModule?.loadRN(), affecting store initialization.
src/components/bottomtab/NoxBottomTab.tsx Renamed navigation variable and updated navigation calls to use an object format.
src/components/explore/SongRow.tsx Modified navigation logic and introduced asynchronous handling in YTSongRow.
src/components/explore/SongTab.tsx Updated navigation logic to use an object format for specifying routes.
src/components/player/PlayerTopInfo.tsx Changed navigation call structure for playlist icon button.
src/components/player/controls/Progress.tsx Adjusted color properties for the ProgressBar component.
src/components/playlist/BiliSearch/BiliSearchbar.tsx Updated navigation logic to use an object format and added early exit check in handleShare.
src/components/playlists/Playlists.tsx Modified navigation logic for playlist access and settings icon.
src/components/playlists/ShuffleAllButton.tsx Changed navigation call structure to use an object format.
src/components/setting/DeveloperSettings.tsx Updated navigation prop type and modified navigation behavior for plugins setting.
src/components/setting/View.tsx Changed navigation prop type and updated navigation behavior for settings.
src/components/setting/appearances/View.tsx Updated navigation prop type and modified navigation behavior for skin settings.
src/enums/BottomTab.ts Modified icon assignments for several routes in IconMap.
src/hooks/useNavigation.ts Introduced NavigateProps interface and updated navigate function signature.
src/types/component.d.ts Added StackNavigationProps interface for navigation properties.
patches/@react-navigation+drawer+7.0.1.patch Introduced drawerStyle parameter to DrawerViewBase function for customizable styling.
src/components/landscape/LandscapeActions.tsx Updated navigation handling to use a custom hook and renamed navigation variable.

Possibly related PRs

  • feat: headless playback #566: The changes in the main PR regarding error handling and UI updates in APMWidget.kt may relate to the headless playback functionality introduced in this PR, as both involve enhancements to the media playback experience in the application.

Poem

🐰 In the land of code where rabbits play,
Changes abound, brightening the day.
With navigation sleek and themes so fine,
Our app hops forward, a true design!
Error handling strong, UI so bright,
Let's celebrate progress, a joyful sight! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (11)
src/components/landscape/AzusaPlayerLandscape.tsx (1)

37-39: Consider consolidating theme selection logic.

While the separate navigation theme handling is good for separation of concerns, the theme selection logic is duplicated. Consider extracting the theme selection into a custom hook or utility function to maintain DRY principles.

+const useThemes = (isDark: boolean) => {
+  const combinedTheme = isDark ? CombinedDarkTheme : CombinedDefaultTheme;
+  const navTheme = isDark ? NavigationDarkTheme : NavigationDefaultTheme;
+  return { combinedTheme, navTheme };
+};

 const AzusaPlayer = () => {
   const playerStyle = useNoxSetting(state => state.playerStyle);
-  const defaultTheme = playerStyle.metaData.darkTheme
-    ? CombinedDarkTheme
-    : CombinedDefaultTheme;
-  const defaultNavTheme = playerStyle.metaData.darkTheme
-    ? NavigationDarkTheme
-    : NavigationDefaultTheme;
+  const { combinedTheme: defaultTheme, navTheme: defaultNavTheme } = 
+    useThemes(playerStyle.metaData.darkTheme);
src/hooks/useSetupPlayer.ts (1)

60-62: Address the TODO comment regarding VIP-specific loading.

The TODO comment indicates that VIP users should have different loading behavior, but this isn't implemented yet.

Would you like me to help implement the VIP-specific loading logic or create a GitHub issue to track this task?

Consider moving loadRN call after VIP check.

The loadRN() call should ideally be placed after checking the VIP status to align with the TODO comment's intent.

-    NoxModule?.loadRN();
+    // Check VIP status first
+    if (!isVIP) {
+      NoxModule?.loadRN();
+    }
src/components/playlists/View.tsx (5)

Line range hint 29-39: Add proper TypeScript types for components.

The BiliCard component and the default export are using any type for props, which reduces type safety. Consider adding proper interfaces:

interface BiliCardProps {
  backgroundURI?: string;
  children: React.ReactNode;
}

interface DrawerViewProps {
  // Add any props passed from the parent
  style?: StyleProp<ViewStyle>;
  children?: React.ReactNode;
}

Also applies to: 86-86


Line range hint 1-1: Remove global ESLint disable and fix dependencies.

Instead of disabling react-hooks/exhaustive-deps globally, address the dependencies properly in each hook. This helps prevent stale closure bugs.

-/* eslint-disable react-hooks/exhaustive-deps */

Also applies to: 42-45


Line range hint 47-63: Extract deep linking logic to a custom hook.

Consider moving the deep linking logic to a custom hook (e.g., useNotificationDeepLink) to improve reusability and separation of concerns:

function useNotificationDeepLink(onNotificationClick: () => void) {
  useEffect(() => {
    function deepLinkHandler(data: { url: string }) {
      if (data.url === 'trackplayer://notification.click') {
        onNotificationClick();
      }
    }
    const subscription = Linking.addEventListener('url', deepLinkHandler);
    return () => subscription.remove();
  }, [onNotificationClick]);
}

Line range hint 86-113: Consider component restructuring for better separation of concerns.

The component handles multiple responsibilities (navigation, deep linking, playlist management). Consider:

  1. Renaming the file to something more specific (e.g., DrawerNavigationView.tsx)
  2. Splitting into smaller, focused components
  3. Moving playlist-related logic to a separate component

This would improve maintainability and make the code easier to test.


I now have enough context to provide a final response about the HACK comment and hook update issue.

Consider moving Android Auto initialization logic to a dedicated effect

The current implementation has two issues:

  • The hook update issue stems from mixing Android Auto initialization with intent handling in the same effect
  • The component is using a workaround by calling buildBrowseTree directly instead of properly handling updates

Suggested changes:

  • Move the intent handling logic to a separate effect that only depends on intentData
  • Add proper dependencies to the effect in useAndroidAutoListener to trigger updates when playlists change
  • Consider splitting Android Auto initialization and intent handling into separate hooks for better separation of concerns
🔗 Analysis chain

Line range hint 42-45: Address the HACK comment.

The comment indicates an issue with hook updates. Consider investigating why the hook isn't updating in its own useEffect and fix the root cause instead of working around it.

Let's check for similar patterns in other files:


Let me gather more context about the HACK comment and the hook update issue.


Let me search for more context about the hook update issue in the specific file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usePlaybackAA hook usage patterns
ast-grep --pattern 'const { $_ } = usePlaybackAA()'

Length of output: 137


Script:

#!/bin/bash
# Search for HACK comments near useEffect and hook usage
rg "HACK" -B 2 -A 2

# Look for useEffect implementations in the same file
ast-grep --pattern 'useEffect(() => {
  $$$
})'

Length of output: 24758


Script:

#!/bin/bash
# Look at the implementation of usePlaybackAA hook and its usage in View.tsx
cat src/components/playlists/View.tsx

# Look at the implementation of usePlaybackAA
cat src/hooks/usePlaybackAA.ts

Length of output: 6121

src/AzusaPlayer.tsx (2)

85-87: Good separation of navigation-specific theming!

The introduction of a separate navigation theme variable improves the architecture by properly separating navigation-specific styling from the general app theme. This makes the theming system more maintainable and follows React Navigation's best practices.


127-131: Consider making drawer width more adaptive.

While using percentage for drawer width is responsive, a hardcoded 70% might not be optimal for all device sizes. Consider:

  1. Using responsive width calculation based on screen size
  2. Making the width configurable through settings

Example implementation:

-drawerStyle={{
-  width: '70%',
-  borderTopRightRadius: 0,
-  borderBottomRightRadius: 0,
-}}
+drawerStyle={{
+  width: Math.min(deviceWidth * 0.7, MAX_DRAWER_WIDTH),
+  borderTopRightRadius: 0,
+  borderBottomRightRadius: 0,
+}}
android/app/src/main/java/com/noxplay/noxplayer/APMWidget.kt (1)

40-49: Consider enhancing error feedback to users.

The error handling for service binding is good, but the TODO comment suggests a need for user feedback. Consider implementing a toast message or notification to inform users when the service binding fails.

 try {
     binder = mBinder as MusicService.MusicBinder
     if (!binder.isBinderAlive) return false
 } catch (e: Exception) {
     // HACK: likely this is bound by another binder. for example
     // android.service.media.MediaBrowserService$ServiceBinder.
-    // TODO: display some error message here?
     Timber.tag("APM-widget").e(e)
+    context?.let {
+        Toast.makeText(it, "Unable to connect to music service", Toast.LENGTH_SHORT).show()
+    }
     return false
 }
patches/react-native-screens+4.0.0.patch (1)

167-167: Fix Syntax Error in Commented-Out Code or Remove It

The commented code on line 167 is missing '+' operators, making it syntactically incorrect. Please correct the syntax or remove the commented code if it's no longer necessary to maintain codebase cleanliness.

Apply this diff to fix the commented code:

-//            return Rect(screen.x.toInt(), -screen.y.toInt(), screen.x.toInt()  screen.width, screen.y.toInt()  screen.height)
+//            return Rect(screen.x.toInt(), -screen.y.toInt(), screen.x.toInt() + screen.width, screen.y.toInt() + screen.height)

Alternatively, consider deleting the commented-out code if it's obsolete.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ae8f8ba and ebb1b20.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (13)
  • android/app/src/main/java/com/noxplay/noxplayer/APMWidget.kt (3 hunks)
  • android/settings.gradle (1 hunks)
  • package.json (4 hunks)
  • patches/@react-navigation+drawer+7.0.0.patch (1 hunks)
  • patches/react-native-paper+5.12.5.patch (1 hunks)
  • patches/react-native-screens+4.0.0.patch (3 hunks)
  • patches/react-native-tab-view+3.5.2.patch (0 hunks)
  • src/AzusaPlayer.tsx (3 hunks)
  • src/components/landscape/AzusaPlayerLandscape.tsx (2 hunks)
  • src/components/player/Lyric.tsx (1 hunks)
  • src/components/playlists/View.tsx (2 hunks)
  • src/hooks/useSetupPlayer.ts (3 hunks)
  • src/stores/initializeStores.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • patches/react-native-tab-view+3.5.2.patch
  • src/stores/initializeStores.ts
🧰 Additional context used
🪛 Biome
src/hooks/useSetupPlayer.ts

[error] 84-85: This case is falling through to the next case.

Add a break or return statement to the end of this case to prevent fallthrough.

(lint/suspicious/noFallthroughSwitchClause)

🔇 Additional comments (17)
patches/react-native-paper+5.12.5.patch (1)

9-10: LGTM! Good accessibility improvement.

Rounding the progress value for accessibility announcements is a good practice as it provides a cleaner, more user-friendly experience for screen reader users.

Let's verify if this accessibility improvement is consistently applied across other progress indicators:

✅ Verification successful

Let me try another search strategy to ensure we have comprehensive coverage of progress-related accessibility implementations.


Let me try one final search focusing specifically on the patch file content and any similar patterns:


Accessibility value rounding is correctly implemented

The search results show that there are only two components with accessibility values in the patch files:

  • The ProgressBar component where the rounding is being added
  • A Slider component that already uses direct values without multiplication (thus no rounding needed)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if other progress indicators in the codebase need similar rounding
# for accessibility values

# Search for other progress indicators that might need similar treatment
rg -A 5 'accessibilityRole=["'\'']progressbar["'\'']'

# Look for other accessibility value calculations that might benefit from rounding
ast-grep --pattern 'accessibilityValue = { $$ }'

Length of output: 624


Script:

#!/bin/bash
# Search for progress-related components and their accessibility implementations
rg -g '!*.test.*' -g '!*.spec.*' -A 10 'progress.*accessibilityValue|accessibilityValue.*progress' 

# Search specifically for ProgressBar components
rg -g '!*.test.*' -g '!*.spec.*' -A 10 'class.*ProgressBar|function.*ProgressBar'

# Look for other numeric accessibility values that might need rounding
rg -g '!*.test.*' -g '!*.spec.*' 'accessibilityValue.*\{.*:.*\*.*\}'

Length of output: 255


Script:

#!/bin/bash
# Check the complete patch file content
cat patches/react-native-paper+5.12.5.patch

# Look for any other accessibility value calculations in patch files
rg -g '*.patch' 'accessibilityValue'

# Search for progress-related components in patch files
rg -g '*.patch' 'ProgressBar|progress'

Length of output: 2185

patches/@react-navigation+drawer+7.0.0.patch (1)

5-11: Verify drawer styling behavior

The change moves drawerStyle from being internally destructured to being passed as a parameter. While the logic appears correct, please verify:

  1. Default styling still works when no drawerStyle is provided
  2. Custom styles are properly applied in all drawer states

Also applies to: 13-20

✅ Verification successful

Drawer style parameter change is safe and properly handled

The change simply moves the drawerStyle from being destructured within the function to being a direct parameter, which is a refactoring that maintains the same functionality. Evidence:

  1. The patch shows a clean move of drawerStyle from internal destructuring to parameter list
  2. The codebase already uses drawerStyle prop as expected (e.g., in AzusaPlayer.tsx)
  3. No other modifications to style handling logic are present in the patch
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for existing drawerStyle usage to ensure compatibility
rg "drawerStyle" --type ts --type tsx --type js --type jsx -B 2 -A 2

Length of output: 96


Script:

#!/bin/bash
# Search for drawerStyle usage without file type restrictions since the patch is modifying React Navigation
rg "drawerStyle" -B 2 -A 2

Length of output: 1181


Script:

#!/bin/bash
# Look for the drawer component implementation to understand style handling
ast-grep --pattern 'function DrawerView$_($$$) {
  $$$
}'

Length of output: 59


Script:

#!/bin/bash
# Check the patch file content for complete context
cat patches/@react-navigation+drawer+7.0.0.patch

Length of output: 972

android/settings.gradle (1)

6-6: Verify the removal of react-native-code-push module.

The removal of the code-push module will affect the app's over-the-air update capabilities. Please confirm if this is intentional and if there's an alternative update strategy in place.

✅ Verification successful

The removal of react-native-code-push is intentional and part of the architectural changes

Based on the git history, we can see that code-push is being systematically removed from the project:

  • The module was removed from settings.gradle
  • Multiple imports of codePush were commented out across the codebase
  • The dependency was removed from the project configuration

This aligns with the PR's objective of implementing a "new arch" and the transition to using Expo modules, which provides its own update mechanisms through EAS Update.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining code-push dependencies or usage

# Check if code-push is still referenced in package.json
echo "Checking package.json for code-push dependencies..."
rg -i "code-push" package.json

# Check for any remaining code-push imports or usage in the codebase
echo "Checking for code-push usage in source files..."
rg -i "code-push" --type js --type ts --type jsx --type tsx

Length of output: 336


Script:

#!/bin/bash
# Let's try a different approach to check for code-push related files and dependencies

# Check package.json with cat and grep instead
echo "Checking package.json for code-push dependencies..."
cat package.json | grep -i "code-push"

# Use find and grep to search for code-push in source files
echo "Checking source files for code-push usage..."
find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.tsx" \) -exec grep -l -i "code-push" {} \;

# Check for code-push related files in android directory
echo "Checking android directory for code-push related files..."
find ./android -type f -exec grep -l -i "code-push" {} \;

# Check git history for code-push removal
echo "Checking git history for code-push removal..."
git log -p | grep -i "code-push"

Length of output: 10888

src/components/landscape/AzusaPlayerLandscape.tsx (1)

62-62: Address technical debt in background color handling.

The HACK comment and background color override with undefined suggest a design issue that should be properly addressed. This could lead to unexpected behavior or styling inconsistencies.

Let's verify the background color handling across the codebase:

Consider:

  1. Document the current background handling approach in MainBackground
  2. Create a proper theming hierarchy instead of using overrides
  3. Remove the HACK comment by implementing a proper fix
src/hooks/useSetupPlayer.ts (2)

14-16: LGTM: Native module import and initialization.

The addition of NativeModules import and module initialization follows React Native best practices.


95-98: Consider a more robust solution for notification click handling.

The current implementation uses a HACK comment and might introduce race conditions. A more robust solution should:

  1. Handle the notification click state in a more predictable way
  2. Avoid relying on playerReady as a trigger for loadRN
  3. Consider implementing a proper state machine for player initialization

Let's verify if this notification click issue is documented or if there are similar workarounds:

src/components/playlists/View.tsx (1)

86-86: LGTM! Good style refactoring.

Moving the inline style to StyleSheet follows React Native best practices and improves maintainability.

Also applies to: 115-115

src/AzusaPlayer.tsx (1)

112-112: Consider addressing the background color technical debt.

While the font configuration is correctly implemented, the HACK comment above suggests there's technical debt in the background color handling. Consider refactoring the background color implementation to eliminate the need for the hack.

Let's check for similar background color workarounds:

package.json (4)

33-35: LGTM: CLI tools version update.

The React Native Community CLI packages have been consistently updated to version 15.1.2.


100-100: Review security implications of custom forks.

Using custom forks for critical packages like react-native-lyric and react-native-track-player could pose security risks. Consider:

  1. Regularly syncing with upstream repositories
  2. Documenting the reasons for using forks
  3. Setting up automated security scanning
#!/bin/bash
# Check if the custom forks have recent commits compared to upstream
echo "Checking react-native-lyric fork..."
gh repo view lovegaoshi/react-native-lyric --json updatedAt,pushedAt

echo "Checking react-native-track-player fork..."
gh repo view lovegaoshi/react-native-track-player --json updatedAt,pushedAt

Also applies to: 113-113


64-64: Verify compatibility between updated packages.

Several interdependent packages have been updated:

  • expo: ^52.0.0-preview.23
  • i18next: ^23.16.5
  • react-native-screens: 4.0.0
  • react-native-tab-view: ^4.0.1

Ensure these versions are compatible, especially:

  1. react-native-screens v4 with React Navigation v7
  2. react-native-tab-view v4 with React Navigation's material-top-tabs
#!/bin/bash
# Check for potential version conflicts in package.json
echo "Checking for version conflicts..."
rg -l "react-native-screens|react-native-tab-view|@react-navigation" 

# Look for any error patterns in the codebase
echo "Checking for common migration issues..."
rg "ScreenStack|TabView|createMaterialTopTabNavigator"

Also applies to: 76-76, 106-106, 111-111


43-46: ⚠️ Potential issue

Verify React Navigation v7 migration changes.

The upgrade to React Navigation v7 introduces breaking changes that require code updates:

  • Screen configuration syntax changes
  • New TypeScript types
  • Updated screen lifecycle behaviors

Please ensure the following migration steps are completed:

✅ Verification successful

React Navigation v7 upgrade appears compatible with existing codebase

The codebase shows proper implementation of React Navigation v7:

  • Correct imports from @react-navigation packages
  • Proper usage of navigation containers and navigators
  • Theme configuration follows v7 patterns with adaptNavigationTheme
  • No deprecated v6 patterns found (like old ref handling or linking configurations)

The navigation setup in both AzusaPlayer.tsx and landscape mode follows current best practices, and no breaking changes from v7 appear to affect the existing implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potentially affected navigation configurations
echo "Checking for affected navigation patterns..."
rg -l "createNativeStackNavigator|createDrawerNavigator|NavigationContainer" 

# Look for common v6 patterns that need updates
echo "Checking for v6 patterns that need updates..."
rg "screenOptions={{[^}]*headerShown:\s*(true|false)[^}]*}}"

Length of output: 2808


Script:

#!/bin/bash
# Check for navigation configuration patterns
echo "Checking navigation configurations..."
rg -A 5 "NavigationContainer|createNativeStackNavigator|createDrawerNavigator" src/

# Check for screen options patterns
echo "Checking screen options..."
rg -A 3 "screenOptions\s*=\s*{" src/

# Check for navigation-related component imports
echo "Checking navigation imports..."
rg "^import.*@react-navigation" src/

Length of output: 8568


Script:

#!/bin/bash
# Check for screen options with fixed syntax
echo "Checking screen options patterns..."
rg -A 3 "screenOptions.*=.*{" src/

# Check for v6 specific navigation patterns that might need updates
echo "Checking for potential v6 patterns..."
rg -A 3 "(useNavigationContainerRef|navigationRef|linking:|useLinking)" src/

# Check for navigation theme usage
echo "Checking navigation theme usage..."
rg -A 3 "(NavigationDarkTheme|NavigationDefaultTheme|NavigationTheme)" src/

Length of output: 3291

src/components/player/Lyric.tsx (1)

131-132: Improved color system usage for karaoke text.

The switch to onSurface and onSurfaceVariant colors aligns better with Material Design principles for text display.

Let's verify the contrast ratios for accessibility:

✅ Verification successful

Based on the search results, I can now generate the final response:

Color contrast verified for karaoke text display

The implementation uses well-defined theme colors with good contrast ratios:

  • onSurface is set to #fcf75e (bright yellow)
  • onSurfaceVariant is set to rgb(202, 200, 165) (light gray)

These colors provide sufficient contrast for karaoke text display, with the bright yellow for active lyrics and a muted gray for inactive ones, ensuring good readability and visual hierarchy.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any custom color overrides or theme definitions that might affect these colors
rg -A 5 "onSurface|onSurfaceVariant" --type ts --type tsx

# Look for any theme configuration files
fd -e ts -e tsx -e json "theme|style|color" --exec cat {} \; | grep -A 10 -B 10 "onSurface\|onSurfaceVariant"

Length of output: 2183

android/app/src/main/java/com/noxplay/noxplayer/APMWidget.kt (1)

57-57: Clarify spinner implementation details.

The TODO comment about showing a spinner needs more context. Consider:

  1. Where should the spinner be displayed in the widget layout?
  2. Should it replace the album art temporarily?
  3. How long should it be shown?

Let's check if the widget layout supports adding a spinner:

✅ Verification successful

Let me check the actual widget layout file to understand the current structure and potential places for the spinner.


Let me check the context where this TODO comment is used to understand when the spinner might be needed.


Consider using the existing album art ImageView for loading state

The TODO appears in bindOrStartService() when the service binding fails and needs to start. Since we have the widget layout context:

  1. The albumArt ImageView (80dp x match_parent) is the ideal place to show a loading indicator
  2. You can overlay a ProgressBar on the album art or replace the album art source with an animated drawable during loading
  3. The spinner should be shown until the service successfully binds or fails

Example implementation:

private fun showLoading(show: Boolean) {
    val views = RemoteViews(context.packageName, R.layout.a_p_m_widget)
    views.setImageViewResource(R.id.albumArt, 
        if (show) R.drawable.loading_spinner 
        else R.mipmap.ic_launcher_foreground)
    // Update widget
}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check widget layout file for potential spinner placement
rg -A 10 "a_p_m_widget" --glob "*.xml"

Length of output: 1917


Script:

#!/bin/bash
# Check the widget layout file
rg -l "layout/a_p_m_widget" --glob "*.xml"
cat android/app/src/main/res/layout/a_p_m_widget.xml

Length of output: 5626


Script:

#!/bin/bash
# Check the APMWidget.kt file for context around the TODO comment
rg -B 5 -A 5 "TODO: show a spinner" android/app/src/main/java/com/noxplay/noxplayer/APMWidget.kt

Length of output: 539

patches/react-native-screens+4.0.0.patch (3)

19-22: Verify the Modified Condition in ScreenFragment

The condition in ScreenFragment.kt has been updated to include screen.container?.topScreen === screen. Please verify that this change behaves as intended and does not introduce any unintended side effects in the animation start event handling.


40-64: Ensure Standard Transitions Provide Desired Animation Effects

Custom animations have been replaced with standard fragment transitions using setTransition. Verify that the new transitions (TRANSIT_FRAGMENT_OPEN, TRANSIT_FRAGMENT_CLOSE, TRANSIT_FRAGMENT_FADE) deliver the intended animations and maintain a consistent user experience.

Also applies to: 71-91


109-162: onCreateAnimator Implementation Looks Correct

The new onCreateAnimator method in ScreenStackFragment.kt effectively handles animation events for system animations. The logic is clear and should improve animation handling.

Comment on lines 1 to 4
diff --git a/node_modules/@react-navigation/drawer/lib/commonjs/views/DrawerView.js b/node_modules/@react-navigation/drawer/lib/commonjs/views/DrawerView.js
index 0563a7c..6315acb 100644
--- a/node_modules/@react-navigation/drawer/lib/commonjs/views/DrawerView.js
+++ b/node_modules/@react-navigation/drawer/lib/commonjs/views/DrawerView.js
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

⚠️ Reconsider modifying node_modules directly

Modifying files in node_modules is generally discouraged as:

  1. Changes will be lost on every npm install
  2. It makes the build non-reproducible
  3. It can cause conflicts with other packages

Consider these alternatives:

  • Fork the package and use your fork
  • Create a proper PR to the original package
  • Use package.json's patch-package to manage patches systematically

Comment on lines +9 to 10
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Expo configuration is not fully aligned with new architecture

The codebase appears to be using a hybrid setup where Expo modules are used alongside bare React Native. While useExpoModules() is added, there are potential issues:

  1. The new architecture flags are not found in android/app/build.gradle
  2. The project seems to be primarily using bare React Native modules (evidenced by numerous direct React Native imports) rather than Expo modules
  3. The Expo configuration is minimal, with only expo-secure-store found in dependencies

To properly support the new architecture with Expo:

  1. Remove useExpoModules() since this project is not primarily Expo-based
  2. Add proper new architecture flags in android/app/build.gradle:
android {
    defaultConfig {
        // Add these configurations
        newArchEnabled true
        hermesEnabled true
    }
}
🔗 Analysis chain

Verify Expo configuration for new architecture.

The addition of useExpoModules() suggests a transition to using Expo modules. When moving to the new architecture:

  1. Ensure all native modules are compatible with Expo
  2. Verify that the app's android/app/build.gradle has the necessary new architecture configurations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Expo and new architecture setup

# Check for new architecture flags in android/app/build.gradle
echo "Checking new architecture configuration..."
rg -A 5 "newArchEnabled" android/app/build.gradle

# Check for Expo configuration
echo "Checking Expo configuration..."
rg "expo" app.json
rg "expo" app.config.js

# Check for potential compatibility issues with native modules
echo "Checking native module imports..."
rg "import.*react-native" --type js --type ts --type jsx --type tsx

Length of output: 511


Script:

#!/bin/bash
# Let's verify with more precise commands

# Check new architecture configuration with broader pattern
echo "Checking Android build configuration..."
cat android/app/build.gradle

# Check Expo configuration in package.json
echo "Checking Expo dependencies..."
cat package.json | grep -A 5 -B 5 "expo"

# Check native module imports with correct syntax
echo "Checking native module imports..."
rg "import.*react-native"

# Check for expo configuration files
echo "Checking for expo config files..."
fd -e json -e js -e ts "app.config"

Length of output: 34569

Comment on lines +84 to +87
case undefined:
await TrackPlayer.pause();
default:
// await TrackPlayer.pause();
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix switch case fallthrough and clarify intent handling.

There are several issues in the intent handling:

  1. The undefined case falls through to default
  2. The commented-out code in default creates ambiguity
  3. Similar pause logic in both cases suggests redundancy

Apply this fix to handle the cases properly:

         case undefined:
           await TrackPlayer.pause();
+          break;
         default:
-          // await TrackPlayer.pause();
+          console.warn(`Unhandled intent: ${intentData}`);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case undefined:
await TrackPlayer.pause();
default:
// await TrackPlayer.pause();
case undefined:
await TrackPlayer.pause();
break;
default:
console.warn(`Unhandled intent: ${intentData}`);
🧰 Tools
🪛 Biome

[error] 84-85: This case is falling through to the next case.

Add a break or return statement to the end of this case to prevent fallthrough.

(lint/suspicious/noFallthroughSwitchClause)

@@ -137,7 +146,7 @@ class APMWidget : AppWidgetProvider() {
val bitmap = binder.service.getCurrentBitmap()?.await()
val croppedBitmap = cropBitmap(bitmap)
val dr = RoundedBitmapDrawableFactory.create(context.resources, croppedBitmap)
dr.cornerRadius = 100f
dr.cornerRadius = 10f
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Review bitmap handling for memory efficiency.

Several concerns with the current implementation:

  1. The commented-out bitmap.recycle() could lead to memory leaks
  2. Fixed scaling to 120x120 might not be optimal for all screen densities

Consider these improvements:

 private fun cropBitmap(bitmap: Bitmap?): Bitmap? {
     if (bitmap == null) return null
     val dimension = bitmap.width.coerceAtMost(bitmap.height)
     val cropped = ThumbnailUtils.extractThumbnail(bitmap, dimension, dimension)
-    // bitmap.recycle()
+    bitmap.recycle()
-    return Bitmap.createScaledBitmap(cropped, 120, 120, false)
+    val scaledSize = context.resources.getDimensionPixelSize(R.dimen.widget_artwork_size)
+    val scaled = Bitmap.createScaledBitmap(cropped, scaledSize, scaledSize, true)
+    cropped.recycle()
+    return scaled
 }

Also add a dimension resource:

<dimen name="widget_artwork_size">120dp</dimen>

Also applies to: 163-165

Comment on lines +10 to +12
+ fun isSystemAnimation(stackAnimation: StackAnimation): Boolean {
+ return stackAnimation === StackAnimation.DEFAULT || stackAnimation === StackAnimation.FADE || stackAnimation === StackAnimation.NONE
+ }
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use '==' Instead of '===' for Enum Comparison in Kotlin

In Kotlin, it's recommended to use '==' to compare enum values for structural equality. Using '===' checks for referential equality, which may not always be reliable for enums.

Apply this diff to fix the comparison operators:

fun isSystemAnimation(stackAnimation: StackAnimation): Boolean {
-    return stackAnimation === StackAnimation.DEFAULT || stackAnimation === StackAnimation.FADE || stackAnimation === StackAnimation.NONE
+    return stackAnimation == StackAnimation.DEFAULT || stackAnimation == StackAnimation.FADE || stackAnimation == StackAnimation.NONE
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
+ fun isSystemAnimation(stackAnimation: StackAnimation): Boolean {
+ return stackAnimation === StackAnimation.DEFAULT || stackAnimation === StackAnimation.FADE || stackAnimation === StackAnimation.NONE
+ }
fun isSystemAnimation(stackAnimation: StackAnimation): Boolean {
return stackAnimation == StackAnimation.DEFAULT || stackAnimation == StackAnimation.FADE || stackAnimation == StackAnimation.NONE
}

carplay delegate doesnt work with newarch until fixed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 10

🧹 Outside diff range and nitpick comments (15)
src/components/playlists/ShuffleAllButton.tsx (2)

13-16: Consider adding error handling for the shuffle operation.

The shuffleAll operation is awaited but lacks error handling. Consider wrapping it in a try-catch block to handle potential failures gracefully.

   const onPressed = async () => {
-    await shuffleAll();
-    navigation.navigate({ route: NoxRoutes.PlayerHome });
+    try {
+      await shuffleAll();
+      navigation.navigate({ route: NoxRoutes.PlayerHome });
+    } catch (error) {
+      console.error('Failed to shuffle playlist:', error);
+      // Handle error appropriately
+    }
   };

Line range hint 1-24: Consider adding TypeScript type definitions.

The component could benefit from explicit TypeScript types for better maintainability and type safety.

+import { NavigationProp } from '@react-navigation/native';
+
+interface Props {
+  navigation: NavigationProp<any>;
+}

-export default () => {
+export default function ShuffleAllButton() {
   const navigation = useNavigation();
   // ... rest of the component
src/enums/BottomTab.ts (1)

18-19: Consider maintaining distinct icons for different music-related routes.

The current changes consolidate multiple routes (Playlist, PlayerCover, Lyrics) to use the same music icon, which might impact user navigation and intuition. For example, using the music icon for the Playlist route instead of the dedicated playlist icon could make it less immediately recognizable.

Consider this alternative mapping to maintain better visual distinction:

-  [NoxRoutes.Playlist]: BottomTabRouteIcons.music,
-  [NoxRoutes.PlayerCover]: BottomTabRouteIcons.music,
-  [NoxRoutes.Lyrics]: BottomTabRouteIcons.music,
+  [NoxRoutes.Playlist]: BottomTabRouteIcons.playlist,
+  [NoxRoutes.PlayerCover]: BottomTabRouteIcons.music,
+  [NoxRoutes.Lyrics]: BottomTabRouteIcons.music,

This maintains the music icon for player-related routes while keeping the playlist icon for the playlist route, improving visual differentiation.

Also applies to: 22-22

src/hooks/useNavigation.ts (1)

7-11: Consider improving type safety for navigation options.

The options parameter is typed as any, which reduces TypeScript's type checking benefits. Consider using React Navigation's parameter types for better type safety.

+import { NavigationState, ParamListBase } from '@react-navigation/native';
+
 interface NavigateProps {
   route: NoxRoutes;
   setIcon?: boolean;
-  options?: any;
+  options?: NavigationState['routes'][number]['params'];
 }
src/components/player/PlayerTopInfo.tsx (1)

Line range hint 10-11: Consider consolidating navigation approaches.

The component currently uses both the navigation prop and the useNavigation hook. Consider standardizing on one approach to improve maintainability and reduce potential confusion.

-export default ({ navigation }: NoxComponent.NavigationProps) => {
-  const navigationGlobal = useNavigation();
+export default () => {
+  const navigation = useNavigation();

Then update the drawer call:

-          onPress={() => navigation.openDrawer()}
+          onPress={() => navigation.navigate({ route: 'DrawerOpen' })}
src/types/component.d.ts (1)

18-23: Consider documenting the navigation architecture.

The codebase now supports both drawer and stack navigation patterns. Consider documenting:

  1. When to use NavigationProps vs StackNavigationProps
  2. The overall navigation hierarchy
  3. Guidelines for choosing between navigation patterns in new components
src/components/player/controls/Progress.tsx (2)

40-44: Consider improving visual hierarchy of progress indicators

The current implementation overlays two progress bars with similar colors (secondary and secondaryContainer), which might make it difficult for users to distinguish between playback progress and fetch progress.

Consider these improvements:

 <ProgressBar
   progress={fetchProgress / 100}
-  color={playerStyle.colors.secondary}
+  color={playerStyle.colors.primary}
   style={[
     styles.progressBarDouble,
-    { backgroundColor: playerStyle.colors.secondaryContainer },
+    { 
+      backgroundColor: playerStyle.colors.secondaryContainer,
+      opacity: 0.5 
+    },
   ]}
 />

This would:

  1. Use a distinct color (primary) for the fetch progress
  2. Reduce opacity to better indicate it's a secondary indicator

Line range hint 15-21: Add error handling for edge cases

The component currently doesn't handle potential edge cases in the progress calculations.

Consider adding safety checks:

 export const Progress: React.FC<{ live?: boolean }> = ({ live }) => {
   const { position, duration } = useProgress();
   const playerStyle = useNoxSetting(state => state.playerStyle);
-  const fetchProgress = useStore(appStore, state => state.fetchProgress);
+  const fetchProgress = useStore(appStore, state => {
+    const progress = state.fetchProgress;
+    return Math.min(Math.max(0, progress), 100);
+  });
+  
+  const safePosition = Math.max(0, position);
+  const safeDuration = Math.max(0, duration);

This ensures:

  1. Fetch progress is always between 0-100
  2. Position and duration are non-negative
src/components/bottomtab/NoxBottomTab.tsx (1)

30-30: Consider keeping the more descriptive variable name.

The change from navigationGlobal to navigationG makes the code less self-documenting. While shorter names might seem convenient, they can make the code harder to understand for new contributors.

-  const navigationG = useNavigation();
+  const navigationGlobal = useNavigation();
src/components/explore/SongTab.tsx (1)

Line range hint 59-65: Navigation change looks good but there are potential improvements needed.

The navigation update to use object format aligns with the codebase-wide pattern. However, there are a few concerns:

  1. The "HACK" comment suggests a workaround that needs proper documentation or fixing.
  2. Using setTimeout for scroll could lead to race conditions or inconsistent behavior.
  3. The sequence of navigation → playback → scroll might cause a jarring user experience.

Consider refactoring the handler to improve reliability and user experience:

 onPress={() => {
-  navigationGlobal.navigate({ route: NoxRoutes.Playlist });
-  playAsSearchList({
-    songs: totalSongs ?? songs,
-    song: item,
-    // HACK: oh well.
-  }).then(() => setTimeout(scroll, 500));
+  // Start playback first to avoid UI delays
+  playAsSearchList({
+    songs: totalSongs ?? songs,
+    song: item,
+  }).then(() => {
+    // Navigate after playback starts
+    navigationGlobal.navigate({ route: NoxRoutes.Playlist });
+    // Use requestAnimationFrame for smoother scrolling
+    requestAnimationFrame(scroll);
+  });
 }}

Would you like me to help document the current HACK or implement a proper fix? Please let me know if you need assistance understanding the root cause.

src/components/explore/SongRow.tsx (2)

Line range hint 45-50: Consider adding error handling for the playback operation.

While the navigation change looks good, the Promise chain lacks error handling which could lead to silent failures.

Consider adding error handling:

 navigationGlobal.navigate({ route: NoxRoutes.Playlist });
 playAsSearchList({
   songs: totalSongs ?? songs,
   song: item,
-}).then(() => setTimeout(scroll, 500));
+}).then(() => setTimeout(scroll, 500))
+  .catch((error) => {
+    console.error('Failed to play song:', error);
+    // Consider showing a user-friendly error message
+  });

Also, consider explaining the purpose of the 500ms delay in a comment, or better yet, use a more deterministic approach for triggering the scroll.


Line range hint 95-95: Address the TODO comment about component abstraction.

The BiliSongRow and YTSongRow components share significant code. Consider creating a base component to reduce duplication.

Here's a suggested approach:

interface BaseSongRowProps {
  songs: Array<{
    cover: string;
    name: string;
    singer?: string;
  }>;
  title?: string;
  onItemPress: (item: any) => Promise<void>;
}

const BaseSongRow: React.FC<BaseSongRowProps> = ({ songs, title, onItemPress }) => {
  // Common implementation here
};

// Then use it like:
export const BiliSongRow = (props: BiliSongCardProp) => (
  <BaseSongRow
    {...props}
    onItemPress={async (item) => {
      // BiliSongRow specific logic
    }}
  />
);
src/components/playlist/BiliSearch/BiliSearchbar.tsx (2)

Line range hint 115-121: Consider enhancing shared data comparison.

While the early return for duplicate data is good, consider normalizing the shared data before comparison to handle equivalent URLs with different formats (e.g., with/without trailing slashes, different protocols).

 const handleShare = useCallback((item?: SharedItem) => {
   if (!item) {
     return;
   }
 
   const { mimeType, data } = item;
-  if (data === sharedData) return;
+  const normalizeUrl = (url: string) => url.trim().toLowerCase().replace(/\/$/, '');
+  if (normalizeUrl(data) === normalizeUrl(sharedData)) return;
   setSharedData(data);
   setSharedMimeType(mimeType);
   handleExternalSearch(data);
   setSearchVal(data);
 }, []);

Line range hint 1-1: Improve type safety by removing 'any' types.

The code uses several any types which reduce type safety. Consider defining proper interfaces for the search results and shared data.

-/* eslint-disable @typescript-eslint/no-explicit-any */
+interface SearchResult {
+  // Define the structure of your search results
+  id: string;
+  title: string;
+  // ... other properties
+}

 interface SharedItem {
   mimeType: string;
   data: string;
-  extraData: any;
+  extraData: Record<string, unknown>;
 }

 interface Props {
-  onSearched: (val: any) => void;
+  onSearched: (val: SearchResult[]) => void;
 }

Also applies to: 24-26, 53-53

src/components/setting/DeveloperSettings.tsx (1)

Line range hint 67-72: Remove commented-out code

The commented-out chatGPTSongName setting should either be implemented or removed. Commented-out code can lead to confusion and maintenance issues.

-  /**
-  chatGPTSongName: {
-    settingName: 'chatGPTResolveSongName',
-    settingCategory: 'GeneralSettings',
-  },
-   */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e1e65f2 and fa17844.

📒 Files selected for processing (16)
  • android/settings.gradle (1 hunks)
  • src/components/bottomtab/NoxBottomTab.tsx (2 hunks)
  • src/components/explore/SongRow.tsx (2 hunks)
  • src/components/explore/SongTab.tsx (1 hunks)
  • src/components/player/PlayerTopInfo.tsx (1 hunks)
  • src/components/player/controls/Progress.tsx (1 hunks)
  • src/components/playlist/BiliSearch/BiliSearchbar.tsx (1 hunks)
  • src/components/playlists/Playlists.tsx (2 hunks)
  • src/components/playlists/ShuffleAllButton.tsx (1 hunks)
  • src/components/playlists/View.tsx (4 hunks)
  • src/components/setting/DeveloperSettings.tsx (2 hunks)
  • src/components/setting/View.tsx (2 hunks)
  • src/components/setting/appearances/View.tsx (2 hunks)
  • src/enums/BottomTab.ts (1 hunks)
  • src/hooks/useNavigation.ts (1 hunks)
  • src/types/component.d.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • android/settings.gradle
  • src/components/playlists/View.tsx
🔇 Additional comments (7)
src/components/playlists/ShuffleAllButton.tsx (1)

15-15: LGTM: Navigation format change aligns with new architecture.

The updated navigation format using object notation is consistent with the architectural changes being implemented across the codebase.

Let's verify the consistency of this navigation pattern across the codebase:

✅ Verification successful

The previous script had an issue with file type recognition. Let's try a more generic search to understand the navigation patterns in the codebase. This will help us verify if the object-style navigation is consistently used across the codebase.


Let's try a different approach by first finding the TypeScript files and then searching within them. This should help us verify the navigation patterns across the codebase.


Based on the search results, I can see that the object-style navigation format navigation.navigate({ route: ... }) is consistently used across the codebase, particularly in:

  1. src/components/playlists/Playlists.tsx:
navigation.navigate({ route: NoxRoutes.PlayerHome });
navigation.navigate({ route: NoxRoutes.Playlist });
navigation.navigate({ route: NoxRoutes.Settings });
  1. src/components/playlists/ShuffleAllButton.tsx:
navigation.navigate({ route: NoxRoutes.PlayerHome });
  1. src/components/playlists/View.tsx:
navigation.navigate({ route: view, setIcon: routeIcon !== undefined });
navigation.navigate({ route: NoxRoutes.PlayerHome });

The navigation format change is consistent with the codebase architecture

The updated object-style navigation format is used consistently across all navigation calls in the codebase, confirming this is part of a standardized architectural pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for navigation.navigate calls to ensure consistent usage of the new format
rg -U "navigation\.navigate\([^{].*?\)" --type ts --type tsx

Length of output: 90


Script:

#!/bin/bash
# Search for navigation.navigate calls with proper file type patterns
rg -U "navigation\.navigate\(" "*.tsx" "*.ts"

# Alternative search to find all navigation patterns
rg -U "navigation\." "*.tsx" "*.ts"

Length of output: 267


Script:

#!/bin/bash
# First, find all TypeScript and TSX files
fd "\.(ts|tsx)$" | while read -r file; do
  # Search for navigation.navigate patterns in each file
  echo "=== $file ==="
  rg -U "navigation\.navigate\(" "$file" || true
done

Length of output: 67854

src/components/player/PlayerTopInfo.tsx (1)

35-37: LGTM: Navigation pattern update is consistent with the new architecture.

The change to use an object-based navigation call aligns with the broader architectural updates across the application.

src/types/component.d.ts (1)

4-4: LGTM! Import statement is properly placed.

The import of NativeStackNavigationProp is correctly positioned alongside other navigation-related imports.

src/components/setting/appearances/View.tsx (1)

19-19: LGTM: Improved type safety with StackNavigationProps

The change from NavigationProps to StackNavigationProps is appropriate as this component is used within a native stack navigator, providing better type safety and access to stack-specific navigation methods.

src/components/bottomtab/NoxBottomTab.tsx (1)

71-73: ⚠️ Potential issue

Fix navigation method calls to use correct React Navigation format.

The current implementation uses a non-standard format that might cause navigation issues. React Navigation's navigate method expects either a route name string or an object with the name property (not route).

Apply this fix to all navigation calls:

-            onPress={() =>
-              navigationG.navigate({ route: NoxRoutes.PlayerHome })
-            }
+            onPress={() => navigationG.navigate(NoxRoutes.PlayerHome)}

-            onPress={() => navigationG.navigate({ route: NoxRoutes.Explore })}
+            onPress={() => navigationG.navigate(NoxRoutes.Explore)}

-            onPress={() => navigationG.navigate({ route: NoxRoutes.Settings })}
+            onPress={() => navigationG.navigate(NoxRoutes.Settings)}

Let's verify if this non-standard navigation format is used elsewhere in the codebase:

Also applies to: 77-77, 81-81

src/components/explore/SongRow.tsx (1)

Line range hint 130-136: Improve async operation flow and error handling.

The current implementation has several potential issues:

  1. Navigation happens before async operations complete
  2. No loading state during playlist fetch
  3. Missing error handling for both async operations

Consider this improved implementation:

-              onPress={async () => {
-                navigationGlobal.navigate({ route: NoxRoutes.Playlist });
-                const playlist = await item.getPlaylist();
-                playAsSearchList({
-                  songs: playlist.songs,
-                  song: playlist.item,
-                }).then(() => setTimeout(scroll, 500));
+              onPress={async () => {
+                try {
+                  // Consider adding a loading indicator here
+                  const playlist = await item.getPlaylist();
+                  navigationGlobal.navigate({ route: NoxRoutes.Playlist });
+                  await playAsSearchList({
+                    songs: playlist.songs,
+                    song: playlist.item,
+                  });
+                  setTimeout(scroll, 500);
+                } catch (error) {
+                  console.error('Failed to load or play playlist:', error);
+                  // Consider showing a user-friendly error message
+                }
+              }}

This revision:

  • Fetches playlist before navigation to ensure data availability
  • Uses proper error handling
  • Maintains consistent async/await pattern

Let's verify the usage of loading indicators in similar components:

src/components/setting/DeveloperSettings.tsx (1)

96-96: LGTM: Props type improvement

The change from NavigationProps to StackNavigationProps better reflects the actual navigation context and provides improved type safety for stack-specific navigation methods.

Comment on lines 17 to 23
const navigate = ({ route, setIcon, options }: NavigateProps) => {
// @ts-expect-error nav v7 hasnt fixed this type yet
navigationGlobal.navigate(route as never, options);
if (setIcon) {
setRoute(IconMap[route]);
}
};
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Navigation calls need to be updated to use consistent object syntax

Found inconsistent usage of the navigation API across the codebase:

  • Most calls use the new object syntax: navigate({ route: NoxRoutes.X })
  • However, some calls in LandscapeActions.tsx still use the old direct style with type assertions:
    navigationGlobal.navigate(NoxRoutes.Lyrics as never)
    navigationGlobal.navigate(NoxRoutes.Explore as never)
    navigationGlobal.navigate(NoxRoutes.Settings as never)

These calls should be updated to use the new object-based signature for consistency:

navigationGlobal.navigate({ route: NoxRoutes.Lyrics })
🔗 Analysis chain

LGTM! Verify navigation calls across the codebase.

The refactored navigation implementation looks good. The ts-expect-error is appropriately documented and necessary for React Navigation v7 compatibility.

Let's verify that all navigation calls have been updated to use the new object-based signature:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining old-style navigation calls
# that haven't been updated to use the new object syntax

# Search for direct navigation calls that might need updating
rg -l "navigate\([^{]" --type ts --type tsx

# Search for potential navigation calls using the old format
ast-grep --pattern 'navigate($route, $setIcon)'

Length of output: 123


Script:

#!/bin/bash
# Let's try a different approach to find navigation calls

# Search for navigate calls without object syntax
rg "navigate\(" -A 2 --type typescript

# Search for potential direct navigation references
rg "navigationGlobal\.navigate\(" -A 2 --type typescript

# Look for any usage of navigate function
ast-grep --pattern 'navigate($$$)'

Length of output: 206


Script:

#!/bin/bash
# Let's try with correct file extensions and simpler patterns

# Search for navigate calls in ts files
rg "navigate\(" -A 2 --type ts

# Search for navigation usage in ts files
rg "navigationGlobal" -A 2 --type ts

# Find files that might contain navigation logic
fd -e ts -e tsx | xargs rg "navigate"

Length of output: 11981

Comment on lines +21 to +23
interface StackNavigationProps {
navigation: NativeStackNavigationProp<ParamListBase>;
}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the content of component.d.ts, I can now generate the final response:

Navigation props interfaces are well-structured but need consolidation

The codebase currently has three navigation-related interfaces in the NoxComponent namespace:

  • NavigationProps (using DrawerNavigationProp)
  • NavigationProps2 (using optional DrawerNavigationProp)
  • StackNavigationProps (using NativeStackNavigationProp)

The new StackNavigationProps interface is well-defined, but having multiple navigation prop interfaces with similar purposes suggests a need to consolidate the navigation pattern. Consider:

  • Merging NavigationProps and NavigationProps2 into a single interface
  • Documenting when to use Stack vs Drawer navigation props
  • Removing the numbered suffix from interface names (NavigationProps2)
🔗 Analysis chain

LGTM! New navigation props interface is well-structured.

The interface follows TypeScript best practices and maintains consistency with existing patterns.

Let's verify the navigation pattern usage across the codebase:


Let me try a different approach to verify the navigation patterns usage.


Let me try one more time with the correct file type flags.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the usage of different navigation props to ensure consistent patterns
# Expected: Files should use either StackNavigationProps or NavigationProps consistently within their context

# Search for usage of both navigation types
echo "Checking navigation prop usage patterns..."
rg -l "NavigationProps|StackNavigationProps" --type ts --type tsx

# Check specific usage contexts
echo -e "\nChecking specific component usage..."
ast-grep --pattern 'interface $_ extends NoxComponent.NavigationProps'
ast-grep --pattern 'interface $_ extends NoxComponent.StackNavigationProps'

Length of output: 430


Script:

#!/bin/bash
# Search for NavigationProps usage with ripgrep, showing context
echo "Checking NavigationProps usage..."
rg "NavigationProps" -A 2 -B 2 --type typescript

# Search for specific navigation type imports and usage
echo -e "\nChecking navigation type imports..."
rg "@react-navigation/(native-stack|drawer)" --type typescript

# Look for component props definitions
echo -e "\nChecking component props definitions..."
rg "Props(\s*=|\s*extends|\s*interface)" -A 3 -B 1 --type typescript

Length of output: 548


Script:

#!/bin/bash
# Search for NavigationProps usage with ripgrep, showing context
echo "Checking NavigationProps usage..."
rg "NavigationProps" -A 2 -B 2 -t ts -t tsx

# Search for specific navigation type imports and usage
echo -e "\nChecking navigation type imports..."
rg "@react-navigation/(native-stack|drawer)" -t ts -t tsx

# Look for component props definitions
echo -e "\nChecking component props definitions..."
rg "Props(\s*=|\s*extends|\s*interface)" -A 3 -B 1 -t ts -t tsx

# Check the specific file where StackNavigationProps is defined
echo -e "\nChecking the types file content..."
cat src/types/component.d.ts

Length of output: 2470

@@ -30,7 +30,7 @@ const MainView = ({ navigation }: NoxComponent.NavigationProps) => {
<SettingListItem
icon={'palette-swatch-variant'}
settingName="SkinSetting"
onPress={() => navigation.navigate(VIEW.SKIN)}
onPress={() => navigation.popTo(VIEW.SKIN)}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Custom navigation method popTo needs to be replaced with standard navigation

The codebase search reveals that:

  1. popTo is used extensively in settings components but has no implementation
  2. The app uses @react-navigation/native-stack for navigation
  3. No custom navigation class or extension implementing popTo was found

Replace with standard React Navigation methods:

- onPress={() => navigation.popTo(VIEW.SKIN)}
+ onPress={() => navigation.navigate(VIEW.SKIN)}

This change should be applied to all similar usages in:

  • src/components/setting/View.tsx
  • src/components/setting/DeveloperSettings.tsx
  • src/components/setting/appearances/View.tsx
🔗 Analysis chain

Verify the custom navigation method

The popTo method is not a standard React Navigation method. This could lead to runtime errors if the method is not properly implemented.

Let's verify the implementation of this custom navigation method:

Consider using standard React Navigation methods if popTo is not well-defined:

-onPress={() => navigation.popTo(VIEW.SKIN)}
+onPress={() => navigation.navigate(VIEW.SKIN)}
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the implementation or type definition of popTo
echo "Searching for popTo implementation..."
rg -t typescript -t javascript "popTo.*=.*{" --no-heading

echo "Searching for popTo type definition..."
rg -t typescript "interface.*Navigation.*{" -A 10 --no-heading

echo "Searching for popTo usage across the codebase..."
rg -t typescript -t javascript "popTo\(" --no-heading

Length of output: 692


Script:

#!/bin/bash
# Search for popTo implementation with fixed regex
echo "Searching for popTo implementation..."
rg "popTo\s*=" -t ts -t tsx -t js -t jsx

echo "Searching for Navigation interface definitions..."
rg "interface.*Navigation" -t ts -t tsx -A 10

echo "Searching for popTo usage..."
rg "popTo" -t ts -t tsx -t js -t jsx

Length of output: 472


Script:

#!/bin/bash
# Search for popTo implementation and usage without file type restrictions
echo "Searching for popTo implementation..."
rg "popTo\s*="

echo "Searching for Navigation interface or type definitions..."
rg "(?:interface|type).*Navigation.*\{" -A 10

echo "Searching for popTo usage..."
rg "\bpopTo\b" -A 2

Length of output: 4947


Script:

#!/bin/bash
# Let's look for the navigation setup and any custom navigation implementations
echo "Searching for navigation setup..."
rg "createNativeStackNavigator|createStackNavigator" -A 5

echo "Searching for custom navigation implementations..."
fd -e ts -e tsx -e js -e jsx | xargs rg "class.*Navigation|extends.*Navigation"

echo "Checking the navigation type definitions..."
fd navigation -i | xargs cat

Length of output: 6063

@@ -79,7 +79,7 @@ export default ({
};

const handleExternalSearch = (data: string) => {
navigationGlobal.navigate(NoxRoutes.Playlist);
navigationGlobal.navigate({ route: NoxRoutes.Playlist });
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Navigation pattern inconsistency detected across components

The codebase shows mixed usage of navigation patterns:

  • Object-based pattern { route: NoxRoutes.Playlist } is used in:

    • src/components/playlist/BiliSearch/BiliSearchbar.tsx
    • src/components/player/PlayerTopInfo.tsx
    • src/components/explore/SongTab.tsx
    • src/components/explore/SongRow.tsx
  • Direct route pattern NoxRoutes.X as never is used in:

    • src/components/landscape/LandscapeActions.tsx (multiple instances)

This inconsistency should be addressed by updating all navigation calls to use the object-based pattern for better type safety and maintainability.

🔗 Analysis chain

Verify consistent navigation pattern usage across the codebase.

The change to object-based navigation ({ route: NoxRoutes.Playlist }) aligns with modern navigation patterns, but we should ensure consistency across all navigation calls.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for direct route navigation patterns that might need updating
rg -t typescript "navigationGlobal\.navigate\([^{].*\)" --glob "src/**/*.tsx"

# Search for the new object-based navigation pattern for comparison
rg -t typescript "navigationGlobal\.navigate\(\{.*route:" --glob "src/**/*.tsx"

Length of output: 231


Script:

#!/bin/bash
# Search for direct route navigation patterns that might need updating
rg "navigationGlobal\.navigate\([^{].*\)" --glob "src/**/*.tsx"

# Search for the new object-based navigation pattern for comparison
rg "navigationGlobal\.navigate\(\{.*route:" --glob "src/**/*.tsx"

# Also search for any other navigation patterns to be thorough
rg "navigationGlobal\.navigate" --glob "src/**/*.tsx" -A 1

Length of output: 3082

Comment on lines 83 to 89
{isAndroid && isIOS && (
<SettingListItem
icon={NoxView.DOWNLOAD}
settingName="DownloadOptions"
onPress={() => navigation.navigate(NoxView.DOWNLOAD)}
onPress={() => navigation.popTo(NoxView.DOWNLOAD)}
settingCategory="Settings"
/>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix platform condition for Download Settings.

The current condition isAndroid && isIOS will always evaluate to false since a device cannot be both Android and iOS simultaneously. This makes the Download Settings completely inaccessible.

Consider using this instead:

-        {isAndroid && isIOS && (
+        {(isAndroid || isIOS) && (
           <SettingListItem
             icon={NoxView.DOWNLOAD}
             settingName="DownloadOptions"
             onPress={() => navigation.popTo(NoxView.DOWNLOAD)}
             settingCategory="Settings"
           />
         )}

Or if you want to restrict it to a specific platform:

-        {isAndroid && isIOS && (
+        {isAndroid && (
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{isAndroid && isIOS && (
<SettingListItem
icon={NoxView.DOWNLOAD}
settingName="DownloadOptions"
onPress={() => navigation.navigate(NoxView.DOWNLOAD)}
onPress={() => navigation.popTo(NoxView.DOWNLOAD)}
settingCategory="Settings"
/>
{(isAndroid || isIOS) && (
<SettingListItem
icon={NoxView.DOWNLOAD}
settingName="DownloadOptions"
onPress={() => navigation.popTo(NoxView.DOWNLOAD)}
settingCategory="Settings"
/>

Comment on lines +37 to 39
interface Props extends NoxComponent.StackNavigationProps {
headerBackVisible?: boolean;
}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Props interface type inconsistency detected across components

The codebase shows inconsistent navigation prop types:

  • src/AzusaPlayer.tsx still uses NoxComponent.NavigationProps
  • src/components/setting/View.tsx uses NoxComponent.StackNavigationProps

This inconsistency could lead to type-safety issues. The migration from NavigationProps to StackNavigationProps should be consistent across all components using stack navigation.

🔗 Analysis chain

LGTM! Props interface correctly updated to use StackNavigationProps.

The change to use StackNavigationProps better aligns with the native stack navigator implementation.

Let's verify the consistency of navigation prop types across related files:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other components using NavigationProps to ensure consistent typing
rg "extends.*NavigationProps" --type tsx

Length of output: 229


Script:

#!/bin/bash
# Search for files with NavigationProps using ripgrep without file type filter
rg "extends.*NavigationProps"

# Also search for StackNavigationProps to understand the migration pattern
rg "extends.*StackNavigationProps"

# Search for .tsx files to verify ripgrep can find them
find . -name "*.tsx"

Length of output: 6023

Comment on lines 55 to 106
onPress={() => navigation.popTo(NoxView.GENERAL)}
settingCategory="Settings"
/>
<SettingListItem
icon={NoxView.SKIN}
settingName="AppearanceSetting"
onPress={() => navigation.navigate(NoxView.SKIN)}
onPress={() => navigation.popTo(NoxView.SKIN)}
settingCategory="Settings"
/>
<SettingListItem
icon={NoxView.LOGIN}
settingName="Login"
onPress={() => navigation.navigate(NoxView.LOGIN)}
onPress={() => navigation.popTo(NoxView.LOGIN)}
settingCategory="Settings"
/>
<SettingListItem
icon={NoxView.BACKUP}
settingName="BackupSetting"
onPress={() => navigation.navigate(NoxView.BACKUP)}
onPress={() => navigation.popTo(NoxView.BACKUP)}
settingCategory="Settings"
/>
<LanguageSettings icon={NoxView.LANGUAGE} />
<SettingListItem
icon={NoxView.ALIST}
settingName="AListOptions"
onPress={() => navigation.navigate(NoxView.ALIST)}
onPress={() => navigation.popTo(NoxView.ALIST)}
settingCategory="Settings"
/>
{isAndroid && isIOS && (
<SettingListItem
icon={NoxView.DOWNLOAD}
settingName="DownloadOptions"
onPress={() => navigation.navigate(NoxView.DOWNLOAD)}
onPress={() => navigation.popTo(NoxView.DOWNLOAD)}
settingCategory="Settings"
/>
)}
<SettingListItem
icon={NoxView.DEVELOPER}
settingName="DeveloperOptions"
onPress={() => navigation.navigate(NoxView.DEVELOPER)}
onPress={() => navigation.popTo(NoxView.DEVELOPER)}
settingCategory="Settings"
/>
<SettingListItem
icon={NoxView.SPLASH_GALLARY}
settingName="SplashSetting"
onPress={() => navigation.navigate(NoxView.SPLASH_GALLARY)}
onPress={() => navigation.popTo(NoxView.SPLASH_GALLARY)}
settingCategory="Settings"
/>
<SettingListItem
icon={NoxView.INFO}
settingName="InfoSetting"
onPress={() => navigation.navigate(NoxView.INFO)}
onPress={() => navigation.popTo(NoxView.INFO)}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Navigation method popTo appears to be undefined

The codebase search reveals that while popTo is being used in the settings components, there is no implementation of this method. The navigation hook (useNavigation.ts) only implements a navigate method, and the app uses React Navigation which doesn't have a built-in popTo method. This will likely cause runtime errors.

Key findings:

  • The useNavigation hook only implements a navigate method
  • The app uses standard React Navigation methods (navigate, openDrawer, closeDrawer)
  • No custom popTo implementation exists in the codebase

Recommendation: Revert back to using navigation.navigate() or implement the popTo method in the navigation hook if a specific navigation behavior is needed.

🔗 Analysis chain

Verify the navigation stack behavior with popTo method.

The change from navigation.navigate() to navigation.popTo() across all settings navigation could significantly alter the navigation stack behavior. This might affect how users navigate back through the settings screens.

Let's verify the implementation and usage of the popTo method:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the popTo method implementation
rg "popTo.*=.*" --type tsx -A 5

# Search for other usages of popTo to ensure consistent behavior
rg "navigation\.popTo\(" --type tsx

Length of output: 229


Script:

#!/bin/bash
# Search for the popTo method implementation and usage with ripgrep
rg "popTo" -t ts -t tsx

# Search for navigation-related types and interfaces
rg "type.*Navigation|interface.*Navigation" -t ts -t tsx

# Look for navigation-related files
fd "navigation" -e ts -e tsx

Length of output: 194


Script:

#!/bin/bash
# Let's examine the navigation hook implementation
cat src/hooks/useNavigation.ts

# Search for popTo without file type restrictions since previous attempts failed
rg "popTo"

# Search for navigation-related code without file type restrictions
rg "navigation" -g "*.ts*" -A 3

Length of output: 25837

@@ -130,7 +131,7 @@ export default () => {
{false && (
<IconButton
icon={'cog'}
onPress={() => navigation.navigate(NoxRoutes.Settings)}
onPress={() => navigation.navigate({ route: NoxRoutes.Settings })}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Remove the unreachable settings navigation code

The settings navigation is actively used across multiple components in the codebase with the same navigation pattern:

  • src/components/landscape/LandscapeActions.tsx
  • src/components/bottomtab/NoxBottomTab.tsx
  • Other components reference it in their configurations

Since this specific button in Playlists.tsx is permanently disabled with false && and there are other accessible ways to reach the settings screen, the unreachable code should be removed to maintain codebase cleanliness.

🔗 Analysis chain

Remove or enable the settings navigation button.

While the navigation syntax update is good, this code is unreachable due to the false && condition. Either:

  1. Remove the unused code, or
  2. Enable the settings button if it's needed

Let's verify if this navigation pattern is used consistently:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check navigation patterns across the codebase
rg "navigation\.navigate\({ route: NoxRoutes\.Settings }\)" --type tsx

Length of output: 310


Script:

#!/bin/bash
# Check navigation patterns across the codebase with proper escaping
rg "navigation\.navigate\(\{.*?route:\s*NoxRoutes\.Settings.*?\}\)" --type tsx

# Also check for other navigation patterns to Settings
rg "navigation\.navigate.*Settings" --type tsx

# Let's also check the NoxRoutes enum definition
rg "enum.*NoxRoutes" -A 10

Length of output: 662


Script:

#!/bin/bash
# Search for navigation patterns without file type restriction
rg "navigation\.navigate.*Settings"

# Check the specific component for conditional rendering
rg -B 5 -A 5 "navigation\.navigate.*Settings" src/components/playlists/Playlists.tsx

# Look for other Settings navigation patterns
rg "NoxRoutes\.Settings"

Length of output: 1260

Comment on lines 71 to 72
navigation.navigate({ route: NoxRoutes.PlayerHome });
navigation.navigate({ route: NoxRoutes.Playlist });
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Sequential navigation pattern needs to be consolidated

The search results confirm that this double navigation pattern (PlayerHomePlaylist) only exists in Playlists.tsx, while other components (View.tsx and ShuffleAllButton.tsx) use single navigation calls to PlayerHome. This inconsistency suggests the sequential navigation is unnecessary.

  • src/components/playlists/Playlists.tsx: Consolidate the two navigation calls into a single navigation to Playlist
  • Other components (View.tsx, ShuffleAllButton.tsx) demonstrate that direct navigation to a single route is the established pattern
🔗 Analysis chain

Review the navigation sequence implementation.

The double navigation sequence (PlayerHomePlaylist) might cause UI flicker and seems unnecessary. Consider:

  1. Why is navigation to PlayerHome required before Playlist?
  2. Could this be simplified to a single navigation call?

Let's check if this pattern is used consistently:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar navigation patterns in other components
rg -A 2 "navigation\.navigate.*PlayerHome.*Playlist" --type tsx

Length of output: 310


Script:

#!/bin/bash
# Search for navigation patterns with better regex
rg "navigation\.navigate.*route:.*PlayerHome" --type tsx -A 3

# Also search for Playlist navigation patterns
rg "navigation\.navigate.*route:.*Playlist" --type tsx -A 3

# Search for any sequential navigation patterns
rg "navigation\.navigate.*\n.*navigation\.navigate" --type tsx -A 3

Length of output: 443


Script:

#!/bin/bash
# Search for navigation patterns without file type restriction and with multiline
rg "navigation\.navigate.*route.*PlayerHome" -A 3

# Search for Playlist navigation patterns
rg "navigation\.navigate.*route.*Playlist" -A 3

# Search for sequential navigation with multiline
rg -U "navigation\.navigate.*\n.*navigation\.navigate" -A 3

Length of output: 1641

@@ -223,7 +223,7 @@ const Home = ({ navigation }: NoxComponent.NavigationProps) => {
<SettingListItem
icon={Icons.plugins}
settingName="PluginsSetting"
onPress={() => navigation.navigate(VIEW.PLUGINS)}
onPress={() => navigation.popTo(VIEW.PLUGINS)}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Navigation method popTo needs to be replaced with standard navigation

The codebase analysis reveals that:

  • popTo is used consistently across multiple components but is not defined in the custom navigation hook (useNavigation.ts)
  • There's no custom implementation of popTo method found in the codebase
  • The app uses React Navigation with standard navigation types (DrawerNavigationProp, NativeStackNavigationProp)

Replace with standard React Navigation methods:

  • In src/components/setting/DeveloperSettings.tsx:
-onPress={() => navigation.popTo(VIEW.PLUGINS)}
+onPress={() => navigation.navigate(VIEW.PLUGINS)}
🔗 Analysis chain

Verify navigation method compatibility

The popTo method is not a standard method in React Navigation's stack navigator. The common methods are navigate, push, pop, popToTop, etc.

Consider using standard navigation methods instead:

-onPress={() => navigation.popTo(VIEW.PLUGINS)}
+onPress={() => navigation.navigate(VIEW.PLUGINS)}

The previous results show that popTo is consistently used across multiple components, suggesting it might be a custom navigation method. Let's verify if there's a custom navigation implementation or type definition that includes this method.


I notice there's a custom navigation hook at src/hooks/useNavigation.ts. Let's examine its implementation to understand if popTo is a custom navigation method defined there.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for popTo usage in navigation
rg "navigation\.popTo" -A 2 -B 2

# Search for potential navigation utility that might define popTo
rg "const.*popTo|function.*popTo" -A 5

Length of output: 3970


Script:

#!/bin/bash
# Search for navigation type definitions or custom navigation implementations
rg "type.*Navigation|interface.*Navigation" -A 5

# Search for potential navigation utility or wrapper
fd -e ts -e tsx -x rg "navigation.*=|createNavigation" -l

# Look for navigation setup or configuration
ast-grep --pattern 'createNavigationContainerRef()' 

Length of output: 2237


Script:

#!/bin/bash
# Check the custom navigation hook implementation
cat src/hooks/useNavigation.ts

# Look for navigation utility implementations
rg "popTo.*=" -A 5 -B 5

# Search for navigation container setup
rg "navigationRef" -A 5 -B 5

Length of output: 776

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
patches/@react-navigation+drawer+7.0.1.patch (1)

8-10: Caution: Direct modification of node_modules

While the parameter addition is logically correct, directly modifying third-party packages in node_modules is discouraged as:

  • Changes will be lost when dependencies are updated
  • It makes the codebase harder to maintain
  • It could cause conflicts with future package updates

Consider these alternatives:

  1. Fork the package and maintain your own version
  2. Create a wrapper component that extends the drawer functionality
  3. Submit a PR to the original package if this is a generally useful feature
src/components/landscape/LandscapeActions.tsx (1)

24-26: Consider strengthening type safety in navigation state handling.

The current implementation uses optional chaining for navigation state access, which is defensive but might mask underlying type issues:

navigation.getState()?.routes?.at(-1)?.name

Consider adding proper type guards:

const state = navigation.getState();
const currentRoute = state.routes[state.routes.length - 1];
const targetRoute = currentRoute?.name === NoxRoutes.Playlist
  ? NoxRoutes.PlaylistsDrawer
  : NoxRoutes.Playlist;
navigation.navigate({ route: targetRoute });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fa17844 and ff740fd.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (12)
  • package.json (4 hunks)
  • patches/@react-navigation+drawer+7.0.1.patch (1 hunks)
  • src/components/explore/SongRow.tsx (2 hunks)
  • src/components/explore/SongTab.tsx (1 hunks)
  • src/components/landscape/LandscapeActions.tsx (4 hunks)
  • src/components/player/PlayerTopInfo.tsx (1 hunks)
  • src/components/playlist/BiliSearch/BiliSearchbar.tsx (1 hunks)
  • src/components/playlists/Playlists.tsx (2 hunks)
  • src/components/setting/DeveloperSettings.tsx (1 hunks)
  • src/components/setting/View.tsx (1 hunks)
  • src/components/setting/appearances/View.tsx (1 hunks)
  • src/hooks/useNavigation.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
  • package.json
  • src/components/explore/SongRow.tsx
  • src/components/explore/SongTab.tsx
  • src/components/player/PlayerTopInfo.tsx
  • src/components/playlist/BiliSearch/BiliSearchbar.tsx
  • src/components/playlists/Playlists.tsx
  • src/components/setting/DeveloperSettings.tsx
  • src/components/setting/View.tsx
  • src/components/setting/appearances/View.tsx
  • src/hooks/useNavigation.ts
🔇 Additional comments (2)
src/components/landscape/LandscapeActions.tsx (2)

18-18: LGTM! Clean variable naming.

The change to navigation is more concise and follows React hooks naming conventions.


7-7: Verify custom navigation hook implementation.

The switch to a custom navigation hook could introduce unexpected behavior if not properly implemented.

Let's verify the custom hook implementation:

✅ Verification successful

Custom navigation hook implementation is correct and safe to use

The custom hook is properly implemented as a wrapper around React Navigation's native useNavigation. It:

  • Correctly imports and uses the official useNavigation from '@react-navigation/native'
  • Adds app-specific functionality (icon management and route setting)
  • Maintains core navigation capabilities through navigate and getState
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the implementation of the custom navigation hook
# Expected: The hook should properly wrap React Navigation's useNavigation

# Look for the custom hook implementation
ast-grep --pattern 'export default function useNavigation() {
  $$$
}'

# Check for any other usages of this custom hook
rg -l "import.*useNavigation.*from.*@hooks/useNavigation"

Length of output: 502


Script:

#!/bin/bash
# Let's check the actual implementation of the custom hook by searching for the file
fd "useNavigation.ts" --type f

# Also search for any file containing useNavigation export
rg "export.*function.*useNavigation" -A 5

# Additionally, let's check if there are any TypeScript type definitions
fd "navigation.d.ts" --type f

Length of output: 131


Script:

#!/bin/bash
# Let's examine the content of the custom hook implementation
cat src/hooks/useNavigation.ts

# Also check for any usage of @react-navigation/native in the project
rg -l "from '@react-navigation/native'" 

# And check the specific usage of useNavigation from react-navigation
rg "useNavigation.*from '@react-navigation/native'"

Length of output: 1261

Comment on lines +14 to +18
drawerHideStatusBarOnOpen,
drawerPosition = direction === 'rtl' ? 'right' : 'left',
drawerStatusBarAnimation,
- drawerStyle,
drawerType = _reactNative.Platform.select({
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using composition instead of modification

Moving drawerStyle from an internal declaration to a parameter is a good change, but modifying the package directly is risky. Instead, consider creating a custom drawer component that wraps the original one:

// CustomDrawer.tsx
import { DrawerView } from '@react-navigation/drawer';

export const CustomDrawer = (props) => {
  const { customDrawerStyle, ...rest } = props;
  
  return (
    <DrawerView
      {...rest}
      drawerStyle={customDrawerStyle}
    />
  );
};

This approach provides the same functionality while maintaining better separation of concerns and package integrity.

Comment on lines +22 to +27
navigation.navigate({
route:
navigation.getState()?.routes?.at(-1)?.name === NoxRoutes.Playlist
? NoxRoutes.PlaylistsDrawer
: NoxRoutes.Playlist,
});
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Standardize navigation method usage and improve type safety.

There are inconsistencies in how navigation is handled:

  1. Some calls use the new object format: { route: NoxRoutes.X }
  2. Others use direct route names with type assertions: NoxRoutes.X as never

Standardize all navigation calls to use the object format:

-onPress={() => navigation.navigate(NoxRoutes.Lyrics as never)}
+onPress={() => navigation.navigate({ route: NoxRoutes.Lyrics })}

-onPress={() => navigation.navigate(NoxRoutes.Explore as never)}
+onPress={() => navigation.navigate({ route: NoxRoutes.Explore })}

-onPress={() => navigation.navigate(NoxRoutes.Settings as never)}
+onPress={() => navigation.navigate({ route: NoxRoutes.Settings })}

Also applies to: 34-34, 67-67, 77-77, 82-82

@lovegaoshi
Copy link
Owner Author

disabling newarch as drawer nested screen UX is very trash rn.

@lovegaoshi lovegaoshi merged commit 9e8f392 into master Nov 11, 2024
5 of 6 checks passed
Copy link

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