From f68685eb0de7453c437d3741d8f43b94beb8f1b1 Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Fri, 20 Oct 2023 01:24:14 +0500 Subject: [PATCH] clear current message when destroyed --- messaginginapp/api/messaginginapp.api | 1 + .../messaginginapp/gist/presentation/GistModalActivity.kt | 2 ++ .../messaginginapp/gist/presentation/GistModalManager.kt | 4 ++++ .../io/customer/messaginginapp/gist/presentation/GistSdk.kt | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/messaginginapp/api/messaginginapp.api b/messaginginapp/api/messaginginapp.api index a2af954f6..5f408c80c 100644 --- a/messaginginapp/api/messaginginapp.api +++ b/messaginginapp/api/messaginginapp.api @@ -201,6 +201,7 @@ public final class io/customer/messaginginapp/gist/presentation/GistSdk : androi public static field dataCenter Ljava/lang/String; public static field siteId Ljava/lang/String; public final fun addListener (Lio/customer/messaginginapp/gist/presentation/GistListener;)V + public final fun clearCurrentMessage ()V public final fun clearListeners ()V public final fun clearUserToken ()V public final fun dismissMessage ()V diff --git a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistModalActivity.kt b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistModalActivity.kt index c695991f4..426603138 100644 --- a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistModalActivity.kt +++ b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/presentation/GistModalActivity.kt @@ -101,6 +101,8 @@ class GistModalActivity : AppCompatActivity(), GistListener, GistViewListener { // If the message is not persistent, dismiss it and inform the callback if (!isPersistentMessage()) { GistSdk.dismissMessage() + } else { + GistSdk.clearCurrentMessage() } super.onDestroy() } 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 5b9beab3c..a1d5eb1e9 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 @@ -58,4 +58,8 @@ internal class GistModalManager : GistListener { override fun onMessageShown(message: Message) {} override fun onAction(message: Message, currentRoute: String, action: String, name: String) {} + + internal fun clearCurrentMessage() { + currentMessage = null + } } 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 0934cfc87..d2253e81d 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 @@ -160,6 +160,10 @@ object GistSdk : Application.ActivityLifecycleCallbacks { gistModalManager.dismissActiveMessage() } + fun clearCurrentMessage() { + gistModalManager.clearCurrentMessage() + } + // Listeners fun addListener(listener: GistListener) {