From 0e06f1652d77d8443ec6d88dad5979e65d287607 Mon Sep 17 00:00:00 2001 From: Patoo <262265744+patoo0x@users.noreply.github.com> Date: Fri, 13 Mar 2026 22:46:14 -0400 Subject: [PATCH] fix: replace Tidio with Chatwoot widget in SupportChat - Replace Tidio WebView (loading external tidio.html) with inline Chatwoot SDK - Uses Chatwoot cloud widget (websiteToken: iXmsgU54be2SiQvgBg77bn9S) - Auto-opens chat on load, fills screen - Simplified error handling and loading state - Removes all Tidio API dependencies --- src/screens/SupportChat.tsx | 175 +++++++++++++----------------------- 1 file changed, 61 insertions(+), 114 deletions(-) diff --git a/src/screens/SupportChat.tsx b/src/screens/SupportChat.tsx index edd9623..f5ec6c3 100644 --- a/src/screens/SupportChat.tsx +++ b/src/screens/SupportChat.tsx @@ -9,94 +9,69 @@ import { StyleSheet, } from 'react-native'; -const SupportChat = () => { - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - const [chatReady, setChatReady] = useState(false); - const webViewRef = useRef(null); +const CHATWOOT_HTML = ` + + + + + + Flash Support + + + +
Connecting to support...
- const chatUrl = 'https://getflash.io/app/tidio.html'; - - const handleLoadStart = () => { - console.log('WebView started loading'); - setLoading(true); - setError(null); - setChatReady(false); - }; + + + +`; + +const SupportChat = () => { + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const webViewRef = useRef(null); - webViewRef.current?.injectJavaScript(injectJS); + const handleLoadEnd = () => { + // WebView loaded, Chatwoot SDK will initialize + setTimeout(() => setLoading(false), 3000); // Fallback timeout }; const handleError = (syntheticEvent: any) => { @@ -111,28 +86,8 @@ const SupportChat = () => { const data = JSON.parse(event.nativeEvent?.data); console.log('Message from WebView:', data); - switch (data.type) { - case 'chatOpened': - setChatReady(true); - console.log('Chat opened successfully'); - break; - case 'chatReady': - setChatReady(true); - console.log('Chat is ready'); - break; - case 'chatError': - console.error('Chat error:', data.error); - setError(`Chat error: ${data.error}`); - break; - case 'chatTimeout': - console.error('Chat timeout after', data.attempts, 'attempts'); - setError('Chat failed to load. Please try refreshing.'); - break; - case 'scriptInjected': - console.log('Script injected at:', data.timestamp); - break; - default: - console.log('Unknown message type:', data.type); + if (data.type === 'chatReady') { + setLoading(false); } } catch (e) { console.log('Raw WebView message:', event.nativeEvent.data); @@ -142,13 +97,11 @@ const SupportChat = () => { const handleRefresh = () => { setError(null); setLoading(true); - setChatReady(false); webViewRef.current?.reload(); }; return ( - {/* Error display */} {error && ( {error} @@ -158,35 +111,29 @@ const SupportChat = () => { )} - {/* Loading overlay */} {loading && ( - Loading Tidio Chat... + Loading Support Chat... )} - {/* WebView */}