Skip to content

Conversation

@nuno-vieira
Copy link
Member

@nuno-vieira nuno-vieira commented Nov 5, 2025

🔗 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

  1. Open the Channel List
  2. Tap on the user avatar on left top corner
  3. Tap on "Show Profile"
  4. Tap on the avatar
  5. Upload an image
  6. From another device check that the user now a new image

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Documentation has been updated in the docs-content repo

Summary by CodeRabbit

Release Notes

  • New Features
    • Users can now tap their profile avatar to change it
    • Image selection options: capture a new photo or pick from device library
    • Loading indicator displays during profile picture upload
    • Success and error notifications confirm upload outcomes
@nuno-vieira nuno-vieira requested a review from a team as a code owner November 5, 2025 13:56
@nuno-vieira nuno-vieira added the 🪧 Demo App An Issue or PR related to the Demo App label Nov 5, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 5, 2025

Walkthrough

Added 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

Cohort / File(s) Summary
Avatar Upload Feature
DemoApp/Screens/UserProfile/UserProfileViewController.swift
Class now conforms to UIImagePickerControllerDelegate and UINavigationControllerDelegate. Added loadingSpinner UI element with layout constraints. Implemented tap gesture handler on avatar imageView to trigger action sheet for photo capture or library selection. Added image picker presentation with camera availability checks and popover handling. Implemented uploadImageAndUpdateProfile pipeline: creates temporary file, builds upload attachment, executes server upload, cleans up resources, and updates user profile. Added alert dialogs for success and error feedback.

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 
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Attention areas:
    • Image picker delegate implementation and lifecycle management
    • Temporary file creation and cleanup logic for proper resource management
    • Upload error handling and user feedback messaging
    • Constraint and layout configuration for the loading spinner
    • Action sheet presentation logic with proper popover handling for iPad compatibility

Suggested reviewers

  • martinmitrevski

Poem

🐰 A tap, a click, an image so fine,
Upload it swift with a loading spine!
Avatar changes with flair and grace,
Success bells ring, with a smile on the face! ✨📸

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main change: adding a Demo App example for uploading a global image and updating the user avatar, which aligns with the changeset.
Linked Issues check ✅ Passed The code changes implement the objective from IOS-1225 by adding a functional Demo App example demonstrating how to upload a global image and update a user avatar using the new upload endpoint.
Out of Scope Changes check ✅ Passed All changes in UserProfileViewController are directly scoped to implementing the avatar upload functionality required by the linked issue, with no extraneous modifications.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add/demo-app-global-upload-example

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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: 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.

📥 Commits

Reviewing files that changed from the base of the PR and between e6dff7a and 48065d8.

📒 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
Comment on lines +336 to +341
let attachment = StreamAttachment(
type: .image,
payload: imageData,
downloadingState: nil,
uploadingState: uploadingState
)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

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. 
@nuno-vieira nuno-vieira merged commit bb94828 into develop Nov 7, 2025
6 of 11 checks passed
@nuno-vieira nuno-vieira deleted the add/demo-app-global-upload-example branch November 7, 2025 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🪧 Demo App An Issue or PR related to the Demo App

3 participants