[Problem/Question]
I’m facing a issue with MessageCollection whenever i load the messages first time from it, its giving the wrong statuses of messages in case of first conversation and any further requests to the message collection returns the correct statuses. I’m unable to understand if it’s caching the messages & statuses are not updated in that case and once it has the updated data from api, it works fine
Also i’m not using the cacheResultHandler response now, using the response from apihandler still facing the same issue
Currently its showing delivered statuses instead of sent
// If problem, please fill out the below. If question, please delete.
// What version of the SDK are you using?
4.21.8
[Reproduction Steps]
- open the conversations after opening the app first time
- tapping on first conversation loads incorrect message statuses
- whenever we refresh the conversations from last screen and coming back to first conversation detail gives the same issue
let groupChannel = channel
let params = self.getMessageParams()
self.messageCollection = SendbirdChat.createMessageCollection(channel: groupChannel, startingPoint: self.startingPoint, params: params)
self.messageCollection?.delegate = self
self.messageCollection?.startCollection(initPolicy: .cacheAndReplaceByApi, cacheResultHandler: { messages, error in
guard error == nil, let newMessages = messages else {
return
}
let messagesList = newMessages.compactMap({ message in
return self.chatMapper.mapToChatMessage(baseMessage: message, groupChannel: groupChannel)
})
if messagesList.isEmpty == true {
let error = NSError(domain: "", code: 400)
}
if messagesList.isEmpty == false {
single(.success(messagesList))
return
}
// Messages are retrieved from the local cache.
}, apiResultHandler: { messages, error in
guard error == nil, let newMessages = messages else {
single(.failure(error!))
return
}
let messagesList = newMessages.compactMap({ message in
return self.chatMapper.mapToChatMessage(baseMessage: message, groupChannel: groupChannel)
})
debugPrint("last message")
debugPrint(messagesList.last?.messageStatus)
single(.success(messagesList))
return
})
[Frequency]
every time refreshing the conversations list