From e951f8bb15157f6d9ce1c57c796b38d3a2e089cc Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 24 Jul 2025 15:50:38 +0200 Subject: [PATCH 1/4] 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); From d0276a232e55a054bfe9d11abb6905a53ed823af Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 24 Jul 2025 16:12:26 +0200 Subject: [PATCH 2/4] Fix external links --- .../main/java/com/robosats/MainActivity.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/android/app/src/main/java/com/robosats/MainActivity.kt b/android/app/src/main/java/com/robosats/MainActivity.kt index 41e02b56..3fdc0cfd 100644 --- a/android/app/src/main/java/com/robosats/MainActivity.kt +++ b/android/app/src/main/java/com/robosats/MainActivity.kt @@ -19,6 +19,8 @@ import android.webkit.WebSettings import android.webkit.WebStorage import android.webkit.WebView import android.webkit.WebViewClient +import android.content.Intent +import android.net.Uri import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.constraintlayout.widget.ConstraintLayout @@ -186,6 +188,38 @@ class MainActivity : AppCompatActivity() { runOnUiThread { updateStatus("Secure connection established. Loading app...") + // Set up WebViewClient that allows external links and deep links to be opened + webView.webViewClient = object : WebViewClient() { + override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { + val url = request.url.toString() + val uri = request.url + + if (url.startsWith("file:///android_asset/")) return false + + try { + Log.d("ExternalLink", "Attempting to open: $url") + + val intent = Intent(Intent.ACTION_VIEW, uri) + if (intent.resolveActivity(packageManager) != null) { + startActivity(intent) + Log.d("ExternalLink", "Successfully opened link in external app") + } else { + Log.w("ExternalLink", "No app found to handle: $url") + if (url.startsWith("http://") || url.startsWith("https://")) { + val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + startActivity(browserIntent) + Log.d("ExternalLink", "Opened http/https link in browser") + } + } + + return true + } catch (e: Exception) { + Log.e("ExternalLink", "Failed to open external link: ${e.message}", e) + return true + } + } + } + // Set up WebChromeClient with restricted permissions webView.webChromeClient = object : WebChromeClient() { override fun onGeolocationPermissionsShowPrompt( From 18a46f6d52a12cfc7be42fe46084d8eb3528d059 Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 24 Jul 2025 16:14:19 +0200 Subject: [PATCH 3/4] Fix comments --- .../src/main/java/com/robosats/WebAppInterface.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/android/app/src/main/java/com/robosats/WebAppInterface.kt b/android/app/src/main/java/com/robosats/WebAppInterface.kt index d85d90a4..dddfd2ea 100644 --- a/android/app/src/main/java/com/robosats/WebAppInterface.kt +++ b/android/app/src/main/java/com/robosats/WebAppInterface.kt @@ -320,12 +320,12 @@ class WebAppInterface(private val context: Context, private val webView: WebView private fun onWsMessage(path: String?, message: String?) { 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 + ?.replace("\\", "\\\\") + ?.replace("'", "\\'") + ?.replace("\"", "\\\"") + ?.replace("\n", "\\n") + ?.replace("\r", "\\r") + ?.replace("\t", "\\t") safeEvaluateJavascript("javascript:window.AndroidRobosats.onWSMessage('$path', '$escapedMessage')") } From f1b6926b1d8cedfb414a6bafa179023561d90289 Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 24 Jul 2025 16:15:04 +0200 Subject: [PATCH 4/4] Fix logs --- frontend/src/basic/TopBar/NotificationsDrawer/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/basic/TopBar/NotificationsDrawer/index.tsx b/frontend/src/basic/TopBar/NotificationsDrawer/index.tsx index 13b7276d..6b890e5d 100644 --- a/frontend/src/basic/TopBar/NotificationsDrawer/index.tsx +++ b/frontend/src/basic/TopBar/NotificationsDrawer/index.tsx @@ -98,7 +98,9 @@ const NotificationsDrawer = ({ const soundType = soundByStatus[orderStatus] ?? 'ding'; const sound = audio[soundType]; - console.log(sound); + + void sound.play(); + void sound.play(); void sound.play(); };