I am using messageKit to create a live messaging portion for my iOS application. I am running into an issue with the avatar circles not loading properly. Sometimes they load sporadically, other-times they don't load at all, and sometimes they don't load then will randomly appear... so I am not sure what to do to ensure they load consistently. Here is an example of where they just load sporadically:
Ideally I'd want it to load like how the native messaging iOS app works where it loads the avatar at the end of blocks of text for the user. If someone could suggest how to go about this, I'm not sure what to do since the behavior is just completely inconsistent.
The function used for loading the images:
//This function shows the avatar
func configureAvatarView(_ avatarView: AvatarView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) {
//If it's current user show current user photo.
if message.sender.senderId == self.docId {
avatarView.loadImageUsingCacheWithUrlString(urlString:self.matchImageURLs[0])
} else {
avatarView.isHidden = true
}
}
*** Note I know the loadImageUsingCacheWithUrlString works correctly as it is used throughout the app. I also notice that sometimes as I send messages, the picture may randomly disappear for some of the messages so basically just more unpredictable behavior.
Hell All the issue was that since the cells are reused when a cell gets set to false, then it affects the rest of the cells, so what I had to do was add
avatarView.isHidden = false
Right below the if statement and that fixed it.