From 1e5f7c071592fa1df5e1597988364232a78ddcb5 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi <90936742+Reckless-Satoshi@users.noreply.github.com> Date: Tue, 30 May 2023 11:38:20 +0000 Subject: [PATCH] Fix connected chat status (#632) --- frontend/src/components/Notifications/index.tsx | 1 + .../TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx | 9 +++++++-- .../TradeBox/EncryptedChat/EncryptedTurtleChat/index.tsx | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Notifications/index.tsx b/frontend/src/components/Notifications/index.tsx index 0f1c3465..a435f618 100644 --- a/frontend/src/components/Notifications/index.tsx +++ b/frontend/src/components/Notifications/index.tsx @@ -35,6 +35,7 @@ const path = window.NativeRobosats === undefined ? '/static/assets/sounds' : 'file:///android_asset/Web.bundle/assets/sounds'; + const audio = { chat: new Audio(`${path}/chat-open.mp3`), takerFound: new Audio(`${path}/taker-found.mp3`), diff --git a/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx b/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx index 0747ada1..fccd6089 100644 --- a/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx +++ b/frontend/src/components/TradeBox/EncryptedChat/EncryptedSocketChat/index.tsx @@ -16,6 +16,11 @@ import { type EncryptedChatMessage, type ServerMessage } from '..'; import ChatBottom from '../ChatBottom'; import { sha256 } from 'js-sha256'; +const audioPath = + window.NativeRobosats === undefined + ? '/static/assets/sounds' + : 'file:///android_asset/Web.bundle/assets/sounds'; + interface Props { orderId: number; status: number; @@ -44,7 +49,7 @@ const EncryptedSocketChat: React.FC = ({ const { t } = useTranslation(); const theme = useTheme(); - const [audio] = useState(() => new Audio(`/static/assets/sounds/chat-open.mp3`)); + const [audio] = useState(() => new Audio(`${audioPath}/chat-open.mp3`)); const [connected, setConnected] = useState(false); const [peerConnected, setPeerConnected] = useState(false); const [peerPubKey, setPeerPubKey] = useState(); @@ -268,7 +273,7 @@ const EncryptedSocketChat: React.FC = ({ /> void; } +const audioPath = + window.NativeRobosats === undefined + ? '/static/assets/sounds' + : 'file:///android_asset/Web.bundle/assets/sounds'; + const EncryptedTurtleChat: React.FC = ({ orderId, robot, @@ -43,7 +48,7 @@ const EncryptedTurtleChat: React.FC = ({ const { t } = useTranslation(); const theme = useTheme(); - const [audio] = useState(() => new Audio(`/static/assets/sounds/chat-open.mp3`)); + const [audio] = useState(() => new Audio(`${audioPath}/chat-open.mp3`)); const [peerConnected, setPeerConnected] = useState(false); const [peerPubKey, setPeerPubKey] = useState(); const [value, setValue] = useState(''); @@ -255,7 +260,7 @@ const EncryptedTurtleChat: React.FC = ({