forked from upstream-mirrors/quik
Mark messages as sending after sending the message now.
Otherwise the scheduled time would never be updated and still be in the future.
This commit is contained in:
@@ -767,6 +767,20 @@ open class MessageRepositoryImpl @Inject constructor(
|
|||||||
return message
|
return message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun markAsSendingNow(messageId: Long) =
|
||||||
|
Realm.getDefaultInstance().use { realm ->
|
||||||
|
realm.refresh()
|
||||||
|
realm.where(Message::class.java)
|
||||||
|
.equalTo("id", messageId)
|
||||||
|
.findFirst()
|
||||||
|
?.let { message ->
|
||||||
|
realm.executeTransaction {
|
||||||
|
message.date = System.currentTimeMillis()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks the message as sending, in case we need to retry sending it
|
* Marks the message as sending, in case we need to retry sending it
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class ActionDelayedMessage @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Action.Send -> {
|
Action.Send -> {
|
||||||
|
messageRepo.markAsSendingNow(message.id)
|
||||||
updateConversations.addAll(
|
updateConversations.addAll(
|
||||||
messageRepo.sendMessage(message).map { it.threadId }
|
messageRepo.sendMessage(message).map { it.threadId }
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -88,4 +88,5 @@ interface MessageRepository {
|
|||||||
|
|
||||||
fun deleteOldMessages(maxAgeDays: Int)
|
fun deleteOldMessages(maxAgeDays: Int)
|
||||||
|
|
||||||
|
fun markAsSendingNow(messageId: Long)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user