Messagekit: Image being added to Avatar ends up being reused for other senders

Created on 11 Mar 2020  路  3Comments  路  Source: MessageKit/MessageKit

Trying to load an image for the Avatar, but it ends up being mixed and matched between both users.

` func configureAvatarView(_ avatarView: AvatarView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) {

    let message = self.viewModel.getMessage(indexPath: indexPath) as? Message
    avatarView.tryLoad(from: message?.user.photoUrl)

}`

Image for the sender sometimes is showing on the receiver message.

documentation question

Most helpful comment

Hey @ahmedwasil
It looks like you are loading and setting the avatar image asynchronously but not cancelling the request when the cell is reused?
You can use something like https://github.com/pinterest/PINRemoteImage that will handle the cancellation for you

All 3 comments

Hey @ahmedwasil
It looks like you are loading and setting the avatar image asynchronously but not cancelling the request when the cell is reused?
You can use something like https://github.com/pinterest/PINRemoteImage that will handle the cancellation for you

Thank You that worked a treat!

@ahmedwasil awesome!

Was this page helpful?
0 / 5 - 0 ratings