mirror of
https://github.com/gotify/android.git
synced 2026-05-06 22:26:15 +08:00
fix: skip already processed messages
This commit is contained in:
@@ -311,6 +311,7 @@ internal class MessagesActivity :
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
Logger.info("OnResume " + javaClass.simpleName)
|
||||
val context = applicationContext
|
||||
val nManager = context.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
nManager.cancelAll()
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.github.gotify.messages.provider
|
||||
import com.github.gotify.client.model.Message
|
||||
import com.github.gotify.client.model.PagedMessages
|
||||
import kotlin.math.max
|
||||
import org.tinylog.kotlin.Logger
|
||||
|
||||
internal class MessageStateHolder {
|
||||
@get:Synchronized
|
||||
@@ -42,6 +43,12 @@ internal class MessageStateHolder {
|
||||
|
||||
@Synchronized
|
||||
fun newMessage(message: Message) {
|
||||
if (lastReceivedMessage >= message.id) {
|
||||
Logger.warn {
|
||||
"Skipping processing message with id ${message.id} as it's already processed (lastReceivedMessage: $lastReceivedMessage)"
|
||||
}
|
||||
return
|
||||
}
|
||||
// If there is a message with pending deletion, its indices are going to change. To keep
|
||||
// them consistent the deletion is undone first and redone again after adding the new
|
||||
// message.
|
||||
|
||||
Reference in New Issue
Block a user