diff --git a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistModalManager.kt b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistModalManager.kt index a1d5eb1e9..b3224b92e 100644 --- a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistModalManager.kt +++ b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistModalManager.kt @@ -14,23 +14,25 @@ internal class GistModalManager : GistListener { } internal fun showModalMessage(message: Message, position: MessagePosition? = null): Boolean { - currentMessage?.let { currentMessage -> - Log.i( - GIST_TAG, - "Message ${message.messageId} not shown, ${currentMessage.messageId} is already showing." - ) - return false - } + synchronized(this) { + currentMessage?.let { currentMessage -> + Log.i( + GIST_TAG, + "Message ${message.messageId} not shown, ${currentMessage.messageId} is already showing." + ) + return false + } - Log.i(GIST_TAG, "Showing message: ${message.messageId}") - currentMessage = message + Log.i(GIST_TAG, "Showing message: ${message.messageId}") + currentMessage = message - val intent = GistModalActivity.newIntent(GistSdk.application) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - intent.putExtra(GIST_MESSAGE_INTENT, Gson().toJson(message)) - intent.putExtra(GIST_MODAL_POSITION_INTENT, position?.toString()) - GistSdk.application.startActivity(intent) - return true + val intent = GistModalActivity.newIntent(GistSdk.application) + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + intent.putExtra(GIST_MESSAGE_INTENT, Gson().toJson(message)) + intent.putExtra(GIST_MODAL_POSITION_INTENT, position?.toString()) + GistSdk.application.startActivity(intent) + return true + } } internal fun dismissActiveMessage() {