Sort delivery status lists by timestamp

This commit is contained in:
Sylvain Berfini 2024-06-06 09:34:21 +02:00
parent 12e7041c57
commit 896b621545
3 changed files with 20 additions and 5 deletions

View file

@ -27,6 +27,7 @@ import org.linphone.core.Address
class MessageBottomSheetParticipantModel @WorkerThread constructor(
address: Address,
val value: String,
val timestamp: Long,
val isOurOwnReaction: Boolean = false,
val onClick: (() -> Unit)? = null
) {

View file

@ -101,10 +101,12 @@ class MessageDeliveryModel @WorkerThread constructor(
errorModels.clear()
for (participant in chatMessage.getParticipantsByImdnState(State.Displayed)) {
val timestamp = participant.stateChangeTime
displayedModels.add(
MessageBottomSheetParticipantModel(
participant.participant.address,
TimestampUtils.toString(participant.stateChangeTime)
TimestampUtils.toString(timestamp),
timestamp
)
)
}
@ -117,10 +119,12 @@ class MessageDeliveryModel @WorkerThread constructor(
)
for (participant in chatMessage.getParticipantsByImdnState(State.DeliveredToUser)) {
val timestamp = participant.stateChangeTime
deliveredModels.add(
MessageBottomSheetParticipantModel(
participant.participant.address,
TimestampUtils.toString(participant.stateChangeTime)
TimestampUtils.toString(timestamp),
timestamp
)
)
}
@ -133,10 +137,12 @@ class MessageDeliveryModel @WorkerThread constructor(
)
for (participant in chatMessage.getParticipantsByImdnState(State.Delivered)) {
val timestamp = participant.stateChangeTime
sentModels.add(
MessageBottomSheetParticipantModel(
participant.participant.address,
TimestampUtils.toString(participant.stateChangeTime)
TimestampUtils.toString(timestamp),
timestamp
)
)
}
@ -149,10 +155,12 @@ class MessageDeliveryModel @WorkerThread constructor(
)
for (participant in chatMessage.getParticipantsByImdnState(State.NotDelivered)) {
val timestamp = participant.stateChangeTime
errorModels.add(
MessageBottomSheetParticipantModel(
participant.participant.address,
TimestampUtils.toString(participant.stateChangeTime)
TimestampUtils.toString(timestamp),
timestamp
)
)
}
@ -164,6 +172,11 @@ class MessageDeliveryModel @WorkerThread constructor(
)
)
displayedModels.sortBy { it.timestamp }
deliveredModels.sortBy { it.timestamp }
sentModels.sortBy { it.timestamp }
errorModels.sortBy { it.timestamp }
Log.i("$TAG Message ID [${chatMessage.messageId}] is in state [${chatMessage.state}]")
Log.i(
"$TAG There are [$readCount] that have read this message, [$receivedCount] that have received it, [$sentCount] that haven't received it yet and [$errorCount] that probably won't receive it due to an error"

View file

@ -93,7 +93,8 @@ class MessageReactionsModel @WorkerThread constructor(
allReactions.add(
MessageBottomSheetParticipantModel(
reaction.fromAddress,
body,
reaction.body,
-1,
isOurOwn
) {
if (isOurOwn) {