-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add skeleton loading and error handling to ServerAvatar #6798
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
base: develop
Are you sure you want to change the base?
feat: add skeleton loading and error handling to ServerAvatar #6798
Conversation
- Add skeleton loader using react-native-skeleton-placeholder while image loads - Add error handling with fallback icon when image fails to load - Add dark mode background for better visibility - Use expo-image callbacks for proper state management - Overlay skeleton on image instead of replacing it - Reset loading/error states when imageUri changes
WalkthroughThe ServerAvatar component is refactored to include stateful image loading and error handling. Loading and error states are tracked, image lifecycle handlers manage state transitions, and conditional rendering displays either a skeleton overlay during loading, an image on success, or a fallback container with a custom icon on error. Dark mode support is added. Changes
Sequence DiagramsequenceDiagram
participant User
participant Component as ServerAvatar Component
participant ImageElement as Image Element
User->>Component: Render with image URL
Component->>Component: useState: loading=true, error=false
Component->>ImageElement: Render image (onLoadStart)
ImageElement->>Component: onLoad event
Component->>Component: Update state: loading=false, error=false
Component->>Component: Render image with skeletonOverlay hidden
alt Image Load Error
ImageElement->>Component: onError event
Component->>Component: Update state: error=true, loading=false
Component->>Component: Render fallbackContainer with CustomIcon
end
alt URL Change
User->>Component: New image URL prop
Component->>Component: Reset state: loading=true, error=false
Component->>ImageElement: Render new image
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)app/views/WorkspaceView/ServerAvatar.tsx (3)
🔇 Additional comments (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
I updated the
ServerAvatarcomponent in WorkspaceView to finally add a proper loading state and error handling. Earlier, the avatar area would just stay blank while the image was loading, and nothing showed up if the image failed. Now the user always sees something — either a skeleton, the real avatar, or a fallback icon.Issue
Fixes bug: #4809
Problem
What I Did
I added everything needed to make the avatar feel responsive and consistent with the rest of the app:
Skeleton Loader
Shows an animated grey placeholder while the avatar loads (same style used across the app).
Error Handling
If the image fails, a fallback "workspace" icon appears instead of a blank area.
Dark Mode Support
Added a grey background in dark mode so the avatar doesn’t disappear into a black background.
Light mode remains transparent.
###Proper State Management
Used
expo-imagecallbacks:onLoadStart→ show skeletononLoad→ hide skeletononError→ show fallbackAlso reset states when the image URL changes so the component always behaves correctly when switching servers.
Changes
In
ServerAvatar.tsx:imageUrichange