diff --git a/app/src/main/kotlin/com/github/gotify/messages/MessagesActivity.kt b/app/src/main/kotlin/com/github/gotify/messages/MessagesActivity.kt index 145928de..f17886b6 100644 --- a/app/src/main/kotlin/com/github/gotify/messages/MessagesActivity.kt +++ b/app/src/main/kotlin/com/github/gotify/messages/MessagesActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/github/gotify/messages/provider/MessageStateHolder.kt b/app/src/main/kotlin/com/github/gotify/messages/provider/MessageStateHolder.kt index d8966ba4..713457da 100644 --- a/app/src/main/kotlin/com/github/gotify/messages/provider/MessageStateHolder.kt +++ b/app/src/main/kotlin/com/github/gotify/messages/provider/MessageStateHolder.kt @@ -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.