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: Avatar styles #1486

Merged
merged 2 commits into from
Jan 8, 2025
Merged

fix: Avatar styles #1486

merged 2 commits into from
Jan 8, 2025

Conversation

alexrisch
Copy link
Collaborator

@alexrisch alexrisch commented Jan 8, 2025

With Expo 52 upgrade I removed an unnecessary Image Background (updated designs didn't need it) for Image but didn't update the styles correctly to set a height/width
Simulator Screenshot - iPhone 15 - 2025-01-08 at 19 33 24

Summary by CodeRabbit

  • New Features
    • Updated navigation behavior to return to the "Chats" screen instead of creating a new instance across multiple components in the New Account flow.
  • Style
    • Updated Avatar component styling to simplify image container rendering.
    • Removed dedicated image container style properties.

@alexrisch alexrisch requested a review from a team as a code owner January 8, 2025 12:34
Copy link
Contributor

coderabbitai bot commented Jan 8, 2025

Walkthrough

The pull request introduces changes across multiple components, primarily focusing on the navigation logic and rendering behavior. The Avatar.tsx component's rendering logic has been simplified by removing a dedicated style for the image container. Additionally, several screens related to new account setup have modified their navigation methods from router.navigate to router.popTo, altering how users return to the "Chats" screen within the navigation stack.

Changes

File Change Summary
components/Avatar.tsx Removed styles.imageContainer from View wrapping Image, simplified style application.
screens/NewAccount/NewAccountConnectWalletScreen.tsx Changed navigation from router.navigate("Chats") to router.popTo("Chats").
screens/NewAccount/NewAccountEphemeraScreen.tsx Changed navigation from router.navigate("Chats") to router.popTo("Chats").
screens/NewAccount/NewAccountPrivateKeyScreen.tsx Changed navigation from router.navigate("Chats") to router.popTo("Chats").
screens/NewAccount/NewAccountPrivyScreen.tsx Changed navigation from router.navigate("Chats") to router.popTo("Chats").
screens/NewAccount/NewAccountUserProfileScreen.tsx Changed navigation from navigation.navigate("Chats") to navigation.popTo("Chats"); adjusted dependency order in useCallback hook.

Possibly related PRs

  • feat: Unread indicator on Pinned Conversations #1302: The changes in the Avatar component directly relate to the main PR's modifications in the Avatar.tsx file, as both involve adjustments to the rendering logic and properties of the Avatar component.
  • feat: Members Query on Conversation List  #1343: The modifications to the GroupAvatar component in this PR are relevant as they involve changes to how group members are managed and displayed, which connects to the layout and rendering logic discussed in the main PR regarding the Avatar component.
  • fix: Fixed Conversation Updated messaging on conversation list #1450: This PR enhances messaging related to conversation updates, which may involve the Avatar component indirectly as it relates to how users perceive updates in conversations, including those involving avatars.
  • fix: Add back button #1484: The addition of the back button in the conversation navigation may affect how users interact with the Avatar component in conversation contexts, linking it to the overall user experience discussed in the main PR.

Suggested reviewers

  • lourou
  • thierryskoda

Poem

🐰 In the code where avatars play,
A rabbit hops with style today.
Navigation's path now clearer and bright,
To "Chats" we pop, a joyful flight!
With simpler styles, the view's a delight,
CodeRabbit's magic in every byte! 🎨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce5c597 and 063164b.

📒 Files selected for processing (5)
  • screens/NewAccount/NewAccountConnectWalletScreen.tsx (1 hunks)
  • screens/NewAccount/NewAccountEphemeraScreen.tsx (1 hunks)
  • screens/NewAccount/NewAccountPrivateKeyScreen.tsx (1 hunks)
  • screens/NewAccount/NewAccountPrivyScreen.tsx (1 hunks)
  • screens/NewAccount/NewAccountUserProfileScreen.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: performance-test
🔇 Additional comments (8)
screens/NewAccount/NewAccountConnectWalletScreen.tsx (2)

Line range hint 1-50: Inconsistency with PR objectives.

This file contains navigation logic changes, but the PR description indicates that it's meant to fix Avatar styles after an Expo 52 upgrade. Please clarify if these navigation changes should be part of this PR or moved to a separate PR.


23-23: Verify navigation stack behavior with router.popTo.

The change from router.navigate to router.popTo could affect how screens are managed in the navigation stack. While this optimization prevents stack buildup, please ensure that:

  1. The "Chats" screen exists in the navigation stack when this is called
  2. Users can still navigate back if needed
✅ Verification successful

Navigation change is consistent and intentional

The router.popTo("Chats") pattern is consistently implemented across all NewAccount screens, while other parts of the app use router.navigate("Chats"). This appears to be an intentional architectural decision to clear the navigation stack after completing account creation flows.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of router.navigate("Chats") that might need similar updates
rg -l 'router\.navigate\(["\']Chats["\']'

# Search for potential edge cases where Chats screen might not be in the stack
ast-grep --pattern 'router.popTo("Chats")'

Length of output: 116


Script:

#!/bin/bash
# Search for all Chats navigation patterns with context
echo "=== Navigate to Chats patterns ==="
rg -A 2 'router\.(navigate|popTo)\([\'""]Chats[\'""]' 

# Search for Chats screen definition
echo -e "\n=== Chats screen definition ==="
rg -A 3 'screen\([\'""]Chats[\'""]'

# Search for navigation setup
echo -e "\n=== Navigation setup patterns ==="
rg -A 2 'createNativeStackNavigator|createStackNavigator'

Length of output: 196


Script:

#!/bin/bash
# Search for navigate to Chats
echo "=== Navigate patterns ==="
rg "router.navigate.*Chats"

# Search for popTo Chats
echo -e "\n=== PopTo patterns ==="
rg "router.popTo.*Chats"

# Search for screen definitions
echo -e "\n=== Screen definitions ==="
rg "screen.*Chats"

Length of output: 731

screens/NewAccount/NewAccountPrivyScreen.tsx (1)

36-36: LGTM! Consistent with other navigation changes.

The change from router.navigate to router.popTo aligns with the navigation pattern updates in other NewAccount screens.

screens/NewAccount/NewAccountPrivateKeyScreen.tsx (1)

34-34: LGTM! Consistent error handling with navigation change.

The change from router.navigate to router.popTo maintains proper error handling while aligning with the navigation pattern updates.

screens/NewAccount/NewAccountEphemeraScreen.tsx (2)

40-40: LGTM! Navigation change with proper error handling.

The change from router.navigate to router.popTo maintains proper error handling and loading state management while aligning with the navigation pattern updates across all NewAccount screens.


Line range hint 1-93: Consider splitting navigation changes into a separate PR.

All reviewed files show a consistent pattern of changing from router.navigate("Chats") to router.popTo("Chats"). While this is a valid optimization to prevent navigation stack buildup, it appears unrelated to the PR's stated objective of fixing Avatar styles after an Expo 52 upgrade. Consider:

  1. Moving these navigation changes to a separate PR for better traceability
  2. Including the Avatar style changes that are mentioned in the PR description but not present in the provided files
screens/NewAccount/NewAccountUserProfileScreen.tsx (2)

50-50: LGTM! Dependency array reordering.

The reordering of dependencies in the useCallback hook is fine as the order doesn't affect functionality.


45-45: Verify navigation stack behavior with popTo.

The change from navigate to popTo is a good improvement as it prevents stack buildup during onboarding. However, let's verify that the "Chats" screen exists in the stack when this is called.

✅ Verification successful

Navigation change to popTo("Chats") is safe and correct

The "Chats" screen is properly configured in the main navigation stack and is accessible from both signed-in and new account flows, making it a reliable target for the popTo navigation command.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if there are any conditional navigations to the Chats screen
# that might affect the stack state when this popTo is called

# Search for navigation setup and route definitions
rg -A 5 "Chats.*Screen" 

# Search for other navigations to Chats screen
rg "navigation\.(navigate|push|replace|popTo)\([\"\']Chats[\"\']"

Length of output: 267


Script:

#!/bin/bash
# Search for navigation configuration and screen definitions
rg -l "createStackNavigator|createBottomTabNavigator|createNativeStackNavigator"

# Search for Chats screen definition or imports
rg "Chats.*Screen"

# Search for navigation to Chats with properly escaped quotes
rg -A 2 'navigation\.(navigate|push|replace|popTo)\(["\']Chats["\']'

Length of output: 338


Script:

#!/bin/bash
# Check navigation configuration files
cat screens/Navigation/Navigation.tsx
cat navigation/OnboardingNavigator.tsx

# Search for Chats screen with fixed quotes
rg -l 'Chats'

# Search for navigation patterns with fixed quotes
rg 'navigation\.' | grep -i chats

Length of output: 13512


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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
Contributor

github-actions bot commented Jan 8, 2025

Performance Comparison Report

  • Current: 01efbb9 - 2025-01-08 14:25:17Z
  • Baseline: main (95d1fb6) - 2025-01-08 14:23:55Z

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Type Duration Count
Avatar Image 10 runs render 0.7 ms → 0.8 ms (+0.1 ms, +14.3%) 1 → 1
Avatar Image 50 runs render 0.8 ms → 0.9 ms (+0.0 ms, +4.9%) 1 → 1
Empty Avatar 10 runs render 1.6 ms → 1.0 ms (-0.6 ms, -37.5%) 🟢 1 → 1
Empty Avatar 50 runs render 1.2 ms → 1.1 ms (-0.1 ms, -9.7%) 1 → 1
Text Component with color prop - 10 runs render 0.7 ms → 0.7 ms 1 → 1
Text Component with default props - 10 runs render 1.2 ms → 0.9 ms (-0.3 ms, -25.0%) 🟢 1 → 1
Text Component with translation key - 10 runs render 0.8 ms → 0.6 ms (-0.2 ms, -25.0%) 🟢 1 → 1
Text Component with weight and size - 10 runs render 0.9 ms → 0.5 ms (-0.4 ms, -44.4%) 🟢 1 → 1
Show details
Name Type Duration Count
Avatar Image 10 runs render Baseline
Mean: 0.7 ms
Stdev: 0.5 ms (69.0%)
Runs: 1 1 1 0 0 0 1 1 1 1
Warmup runs: 1

Current
Mean: 0.8 ms
Stdev: 0.4 ms (52.7%)
Runs: 1 1 0 1 1 1 1 1 1 0
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Avatar Image 50 runs render Baseline
Mean: 0.8 ms
Stdev: 0.5 ms (58.8%)
Runs: 0 1 1 1 1 1 1 2 1 0 1 1 1 0 2 0 1 1 1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1
Warmup runs: 1

Current
Mean: 0.9 ms
Stdev: 0.4 ms (40.8%)
Runs: 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 10 runs render Baseline
Mean: 1.6 ms
Stdev: 0.5 ms (32.3%)
Runs: 2 2 1 1 1 2 1 2 2 2
Warmup runs: 3

Current
Mean: 1.0 ms
Stdev: 0.5 ms (47.1%)
Runs: 1 1 1 1 1 2 1 0 1 1
Warmup runs: 2
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 50 runs render Baseline
Mean: 1.2 ms
Stdev: 0.5 ms (38.4%)
Runs: 2 1 2 1 1 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 0 1 1 2 2 1 1 2 2 1 1 1 1 2 1 2 1 1 2 1 1 1 2 1 1 1 1
Warmup runs: 1

Current
Mean: 1.1 ms
Stdev: 0.3 ms (29.3%)
Runs: 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Warmup runs: 2
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with color prop - 10 runs render Baseline
Mean: 0.7 ms
Stdev: 0.5 ms (69.0%)
Runs: 0 1 1 1 1 1 1 0 0 1
Warmup runs: 1

Current
Mean: 0.7 ms
Stdev: 0.5 ms (69.0%)
Runs: 0 1 1 1 1 1 1 0 0 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with default props - 10 runs render Baseline
Mean: 1.2 ms
Stdev: 0.6 ms (52.7%)
Runs: 2 2 1 2 1 1 1 0 1 1
Warmup runs: 4

Current
Mean: 0.9 ms
Stdev: 0.6 ms (63.1%)
Runs: 1 1 1 2 1 0 1 0 1 1
Warmup runs: 5
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with translation key - 10 runs render Baseline
Mean: 0.8 ms
Stdev: 0.4 ms (52.7%)
Runs: 1 0 1 1 0 1 1 1 1 1
Warmup runs: 1

Current
Mean: 0.6 ms
Stdev: 0.5 ms (86.1%)
Runs: 0 1 1 0 1 1 0 0 1 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with weight and size - 10 runs render Baseline
Mean: 0.9 ms
Stdev: 0.3 ms (35.1%)
Runs: 1 1 1 1 1 1 1 1 1 0
Warmup runs: 0

Current
Mean: 0.5 ms
Stdev: 0.5 ms (105.4%)
Runs: 1 1 0 0 1 0 1 0 0 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Render Count Changes

There are no entries

Render Issues

There are no entries

Added Scenarios

There are no entries

Removed Scenarios

There are no entries

Generated by 🚫 dangerJS against 063164b

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
components/Avatar.tsx (1)

Line range hint 50-61: Consider standardizing the style application approach.

For consistency with the placeholder implementation, consider explicitly setting size and borderRadius on the Image wrapper View:

-    <View style={style}>
+    <View
+      style={StyleSheet.flatten([
+        style,
+        { width: size, height: size, borderRadius: size / 2 },
+      ])}
+    >

This ensures consistent sizing behavior between image and placeholder states.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95d1fb6 and ce5c597.

📒 Files selected for processing (1)
  • components/Avatar.tsx (1 hunks)
🔇 Additional comments (1)
components/Avatar.tsx (1)

Line range hint 50-61: Verify layout consistency across different style configurations.

The removal of styles.imageContainer creates an asymmetry between image and placeholder styling. While the Image component maintains its dimensions through styles.image, the View wrapper now relies solely on external styling.

Please verify that the avatar maintains proper layout and alignment in these scenarios:

  1. Without any external style prop
  2. With margin/padding in the style prop
  3. Within flex containers

Run this script to find avatar usage patterns:

✅ Verification successful

Style changes maintain layout consistency across the codebase

The removal of styles.imageContainer is safe as the Avatar component:

  • Maintains proper layout through the parent View's style prop
  • Preserves size constraints via styles.image
  • Shows consistent usage across various layout contexts (flex, fixed, etc.)
  • Successfully integrates with the theme's sizing system
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Avatar component usage patterns
rg -t tsx -t jsx "Avatar" -A 3 -B 1

Length of output: 63


Script:

#!/bin/bash
# Find TypeScript/React files containing Avatar
fd -e ts -e tsx -e jsx | xargs rg "Avatar" -l

# Show Avatar imports and usages with context
fd -e ts -e tsx -e jsx | xargs rg "Avatar" -B 2 -A 3

# Look specifically for style props passed to Avatar
fd -e ts -e tsx -e jsx | xargs rg "<Avatar.*style" -B 1 -A 2

Length of output: 79911

Updates to work with Navigation v7
@@ -47,7 +47,7 @@ function Avatar({
setDidError(false);
}, []);
return uri && !didError ? (
<View style={[styles.imageContainer, style]}>
<View style={style}>
Copy link

Choose a reason for hiding this comment

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

The style prop is being applied to a wrapper View that no longer has width/height constraints. This could lead to incorrect sizing of the avatar. Consider either:

  1. Moving the dimension styles back to an imageContainer style object, or
  2. Removing the View wrapper and applying style directly to the Image component

The second option would reduce nesting and simplify the component structure.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

@alexrisch alexrisch merged commit 103d764 into main Jan 8, 2025
6 checks passed
@alexrisch alexrisch deleted the ar/fix-avatar branch January 8, 2025 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants