Open MakChan opened 3 years ago
@MakChan Have any solution?
This is reproducible with following steps:
This is happening because observeChatState
is called every time startChat
is called, even if chat state observer was attached before
I created this patch file react-native-zendesk-chat+0.4.1.patch
as temporary solution, tested it and seems to fix the issue
diff --git a/node_modules/react-native-zendesk-chat/android/src/main/java/com/taskrabbit/zendesk/RNZendeskChatModule.java b/node_modules/react-native-zendesk-chat/android/src/main/java/com/taskrabbit/zendesk/RNZendeskChatModule.java
index 143efb9..bb2717f 100644
--- a/node_modules/react-native-zendesk-chat/android/src/main/java/com/taskrabbit/zendesk/RNZendeskChatModule.java
+++ b/node_modules/react-native-zendesk-chat/android/src/main/java/com/taskrabbit/zendesk/RNZendeskChatModule.java
@@ -358,6 +358,11 @@ public class RNZendeskChatModule extends ReactContextBaseJavaModule {
// https://support.zendesk.com/hc/en-us/articles/360055343673
public void setupChatStartObserverToSetVisitorInfo(){
+ // Stop if we already have chat state observer
+ if (observationScope != null) {
+ return;
+ }
+
// Create a temporary observation scope until the chat is started.
observationScope = new ObservationScope();
Chat.INSTANCE.providers().chatProvider().observeChatState(observationScope, new Observer<ChatState>() {
@@ -366,8 +371,10 @@ public class RNZendeskChatModule extends ReactContextBaseJavaModule {
ChatSessionStatus chatStatus = chatState.getChatSessionStatus();
// Status achieved after the PreChatForm is completed
if (chatStatus == ChatSessionStatus.STARTED) {
- observationScope.cancel(); // Once the chat is started disable the observation
- observationScope = null; // Clean things up to avoid confusion.
+ if (observationScope != null) {
+ observationScope.cancel(); // Once the chat is started disable the observation
+ observationScope = null; // Clean things up to avoid confusion.
+ }
if (pendingVisitorInfo == null) { return; }
// Update the information MID chat here. All info but Department can be updated
Device: Samsung Galaxy S20+ (SM-G985F) Android 11
Versions: react-native 0.64.2 react-native-zendesk-chat 0.4.1