- Notifications
You must be signed in to change notification settings - Fork 227
Add Demo App Example to upload global image and update user avatar #3870
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
Conversation
WalkthroughAdded avatar upload functionality to UserProfileViewController. Implemented image picker integration with action sheet UI, loading state management, and an upload pipeline that handles image selection, temporary file creation, server upload, and user profile updates with success/error feedback. Changes
Sequence Diagram(s)sequenceDiagram participant User participant UI as UserProfileViewController participant ImagePicker as UIImagePickerController participant Server as StreamChat API User->>UI: Tap avatar image UI->>UI: Show action sheet User->>UI: Select "Take Photo" or "Choose from Library" UI->>ImagePicker: Present image picker User->>ImagePicker: Select image ImagePicker->>UI: didFinishPickingMediaWithInfo UI->>UI: Show loading spinner UI->>UI: Create temporary file UI->>Server: Upload image Server-->>UI: Upload successful UI->>Server: Update user profile Server-->>UI: Profile updated UI->>UI: Hide loading spinner UI->>UI: Show success alert Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
DemoApp/Screens/UserProfile/UserProfileViewController.swift(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.swift
📄 CodeRabbit inference engine (AGENTS.md)
**/*.swift: Respect .swiftlint.yml rules; do not suppress SwiftLint rules broadly—scope and justify any exceptions
Adhere to the project’s zero warnings policy—fix new warnings and avoid introducing any
Files:
DemoApp/Screens/UserProfile/UserProfileViewController.swift
🧬 Code graph analysis (1)
DemoApp/Screens/UserProfile/UserProfileViewController.swift (3)
Sources/StreamChat/Controllers/CurrentUserController/CurrentUserController.swift (1)
updateUserData(251-280)Sources/StreamChat/ChatClient.swift (1)
upload(656-666)Sources/StreamChat/Workers/CurrentUserUpdater.swift (2)
updateUserData(22-60)updateUserData(351-375)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build Test App and Frameworks
- GitHub Check: Test LLC (Debug)
- GitHub Check: Metrics
| let attachment = StreamAttachment( | ||
| type: .image, | ||
| payload: imageData, | ||
| downloadingState: nil, | ||
| uploadingState: uploadingState | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StreamAttachment payload must conform to AttachmentPayload.
StreamAttachment is generic over Payload: AttachmentPayload. Passing raw Data here forces the compiler to infer Payload == Data, which does not conform to AttachmentPayload, so this code will not compile. Please build an appropriate payload (e.g. ImageAttachmentPayload or AnyAttachmentPayload.image(...)) and pass that to StreamAttachment, while keeping the bytes in AttachmentUploadingState as you do now. Once the payload is a proper AttachmentPayload, the upload call will compile.
🤖 Prompt for AI Agents
In DemoApp/Screens/UserProfile/UserProfileViewController.swift around lines 336 to 341, the StreamAttachment initializer is being passed raw Data which causes the compiler error because Payload must conform to AttachmentPayload; replace the raw Data payload with a proper AttachmentPayload (e.g. construct an ImageAttachmentPayload or use AnyAttachmentPayload.image(...) containing metadata and reference to the image) and pass that payload into StreamAttachment, while keeping the actual bytes in the AttachmentUploadingState as you already do so the upload call will compile.
🔗 Issue Links
Related: https://linear.app/stream/issue/IOS-1225/add-docs-for-new-upload-endpoint
🎯 Goal
Add Demo App Example to upload a global image and update the user avatar.
📝 Summary
Add Demo App Example to upload a global image and update the user avatar.
🧪 Manual Testing Notes
☑️ Contributor Checklist
docs-contentrepoSummary by CodeRabbit
Release Notes