From e951f8bb15157f6d9ce1c57c796b38d3a2e089cc Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 24 Jul 2025 15:50:38 +0200 Subject: [PATCH] Fix chat --- .../app/src/main/java/com/robosats/WebAppInterface.kt | 9 ++++++++- frontend/src/basic/TopBar/NotificationsDrawer/index.tsx | 8 ++++++-- .../TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/android/app/src/main/java/com/robosats/WebAppInterface.kt b/android/app/src/main/java/com/robosats/WebAppInterface.kt index bd32caf3..d85d90a4 100644 --- a/android/app/src/main/java/com/robosats/WebAppInterface.kt +++ b/android/app/src/main/java/com/robosats/WebAppInterface.kt @@ -319,7 +319,14 @@ class WebAppInterface(private val context: Context, private val webView: WebView } private fun onWsMessage(path: String?, message: String?) { - safeEvaluateJavascript("javascript:window.AndroidRobosats.onWSMessage('$path', '$message')") + val escapedMessage = message + ?.replace("\\", "\\\\") // Escape backslashes first + ?.replace("'", "\\'") // Escape single quotes + ?.replace("\"", "\\\"") // Escape double quotes + ?.replace("\n", "\\n") // Escape newlines + ?.replace("\r", "\\r") // Escape carriage returns + ?.replace("\t", "\\t") // Escape tabs + safeEvaluateJavascript("javascript:window.AndroidRobosats.onWSMessage('$path', '$escapedMessage')") } private fun onWsError(path: String?) { diff --git a/frontend/src/basic/TopBar/NotificationsDrawer/index.tsx b/frontend/src/basic/TopBar/NotificationsDrawer/index.tsx index 68ee7583..13b7276d 100644 --- a/frontend/src/basic/TopBar/NotificationsDrawer/index.tsx +++ b/frontend/src/basic/TopBar/NotificationsDrawer/index.tsx @@ -23,7 +23,7 @@ import arraysAreDifferent from '../../../utils/array'; import getSettings from '../../../utils/settings'; const path = - getSettings().client == 'mobile' + getSettings().client === 'mobile' ? 'file:///android_asset/static/assets/sounds' : '/static/assets/sounds'; @@ -98,12 +98,16 @@ const NotificationsDrawer = ({ const soundType = soundByStatus[orderStatus] ?? 'ding'; const sound = audio[soundType]; + console.log(sound); void sound.play(); }; const loadNotifciationsNostr = (): void => { const tokens = Object.keys(garage.slots); - if (!arraysAreDifferent(subscribedTokens, tokens)) return; + if (!arraysAreDifferent(subscribedTokens, tokens)) { + setLoading(false); + return; + } cleanUpNotifications(); setSubscribedTokens(tokens); diff --git a/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx b/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx index cb4a2b9c..55c62ed6 100644 --- a/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx +++ b/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx @@ -21,7 +21,7 @@ import { Send } from '@mui/icons-material'; const audioPath = getSettings().client == 'mobile' - ? 'file:///android_asset//static/assets/sounds' + ? 'file:///android_asset/static/assets/sounds' : '/static/assets/sounds'; interface Props { @@ -135,7 +135,7 @@ const EncryptedSocketChat: React.FC = ({ ); connection.onMessage((message) => { - setServerMessages((prev) => [...prev, message]); + setServerMessages((prev) => [...prev, message as ServerMessage]); }); connection.onClose(() => { setConnected(false);