diff --git a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt index b52ccc7b1..146715da2 100644 --- a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt +++ b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt @@ -23,6 +23,7 @@ import retrofit2.converter.gson.GsonConverterFactory class Queue : GistListener { private var localMessageStore: MutableList = mutableListOf() + private var shownMessageQueueIds = mutableSetOf() init { GistSdk.addListener(this) @@ -149,6 +150,11 @@ class Queue : GistListener { } private fun processMessage(message: Message) { + if (message.queueId != null && shownMessageQueueIds.contains(message.queueId)) { + Log.i(GIST_TAG, "Duplicate message ${message.queueId} skipped") + return + } + val gistProperties = GistMessageProperties.getGistProperties(message) gistProperties.routeRule?.let { routeRule -> try { @@ -188,6 +194,7 @@ class Queue : GistListener { GIST_TAG, "Logging view for user message: ${message.messageId}, with queue id: ${message.queueId}" ) + shownMessageQueueIds.add(message.queueId) removeMessageFromLocalStore(message) gistQueueService.logUserMessageView(message.queueId) } else { diff --git a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistSdk.kt b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistSdk.kt index 5a5f12073..9b51a2f44 100644 --- a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistSdk.kt +++ b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistSdk.kt @@ -153,6 +153,7 @@ object GistSdk : Application.ActivityLifecycleCallbacks { Log.e(GIST_TAG, "Failed to show message: ${e.message}", e) } } + return if (messageShown) message.instanceId else null }