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

ChatChannelListItem no longer loading provided avatar #602

Closed
ktreangen-at-ramsey opened this issue Sep 11, 2024 · 2 comments
Closed

ChatChannelListItem no longer loading provided avatar #602

ktreangen-at-ramsey opened this issue Sep 11, 2024 · 2 comments

Comments

@ktreangen-at-ramsey
Copy link

ktreangen-at-ramsey commented Sep 11, 2024

What did you do?

Updated from version 4.60.0 to 4.62.0

What did you expect to happen?

That custom avatars provided through the following ViewFactory implementation would work as they do in 4.60.0

  @MainActor
  func makeChannelListItem(
      channel: ChatChannel,
      channelName: String,
      avatar: UIImage,
      onlineIndicatorShown: Bool,
      disabled: Bool,
      selectedChannel: Binding<ChannelSelectionInfo?>,
      swipedChannelId: Binding<String?>,
      channelDestination: @escaping (ChannelSelectionInfo) -> ChatChannelView<CustomStreamChatChannelListFactory>,
      onItemTap: @escaping (ChatChannel) -> Void,
      trailingSwipeRightButtonTapped: @escaping (ChatChannel) -> Void,
      trailingSwipeLeftButtonTapped: @escaping (ChatChannel) -> Void,
      leadingSwipeButtonTapped: @escaping (ChatChannel) -> Void
  ) -> ChatChannelListItem {
      return ChatChannelListItem(
          channel: channel,
          channelName: channelName,
          avatar: <custom UIImage here>
          onlineIndicatorShown: false,
          onItemTap: onItemTap
      )
  }

What happened instead?

Default / empty avatars are loaded within each ChatChannelListItem instead of the custom avatar that is passed through the ChatChannelListItem initializer.

GetStream Environment

GetStream Chat version: 4.62.0
GetStream Chat frameworks: StreamChatSwiftUI
iOS version: 17.5
Swift version: 5
Xcode version: 15.4
Device: Simulator

Additional context

This appears to have been introduced in 4.61.0 through the following change: e4a405e#diff-8560b06fdfd635f730bc8b770188c74f87f3f61bf566bc2568ae78954d3a0422R49.

My organization does not use any sort of remote avatars and we want to build and show these locally within our iOS application itself. If there a way to still do this in 4.61.0+ through ChatChannelListItem?

@laevandus
Copy link
Contributor

Hi,

The best way for providing custom avatars is using a custom ChannelHeaderLoader.

Here is an example.
Configure your StreamChat instance like this:

let utils = Utils(
  channelHeaderLoader: CustomChannelHeaderLoader()
)
streamChat = StreamChat(chatClient: chatClient, utils: utils)

where

class CustomChannelHeaderLoader: ChannelHeaderLoader {
  override func image(for channel: ChatChannel) -> UIImage {
    UIImage(resource: .STREAMMARK) // my custom image
  }
}
Screenshot 2024-09-12 at 09 46 53

Please let me know if you need any additional information.

Best,
Toomas

@ktreangen-at-ramsey
Copy link
Author

ktreangen-at-ramsey commented Sep 12, 2024

Hello @laevandus ,

I actually tried this previously but it turns out the image(:) func is not open and therefore we cannot override it.

public func image(for channel: ChatChannel) -> UIImage

Screenshot 2024-09-12 at 8 39 08 AM

Regards,
Kurt

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

No branches or pull requests

2 participants