Handle single Avatar for continuous multiple messages.
dsrijan opened this issue · comments
New issue checklist
- I have read the
README
, documentation, and FAQ. - Contributing guidelines confirmation: ____
- I have searched existing issues and this is not a duplicate.
General information
JSQMessagesViewController
version:- iOS version: 10.0
- Devices/Simulators: Device
- Reproducible in the demo project? (Yes/No): Yes
- Any related issues:No
What happened?
I have a feature related query. Right now when we are sending multiple message at once, then for each message single avatar is showing. It means, if I am sending 3 messages continuously then 3 avatar also shows with bubble, but I want only one avatar for continuous message.The same case applies to recived messages also. If I am recieving regular more than 1 message, but I want bubbles for all messages but only one avatar. Is it possible to handle or not using JSQ. Let me know urgently asap
This should work:
override func collectionView(_ collectionView: JSQMessagesCollectionView, avatarImageDataForItemAt indexPath: IndexPath) -> JSQMessageAvatarImageDataSource? {
let index = indexPath.item
let previous = index == 0 ? "" : messages[index - 1].senderId
let current = messages[index].senderId
return previous == current ? nil : getAvatar(current)
}
thanks, @acjh. 💯