Fix connected chat status (#632)

This commit is contained in:
Reckless_Satoshi 2023-05-30 11:38:20 +00:00 committed by GitHub
parent f3a7701166
commit 1e5f7c0715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -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`),

View File

@ -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<Props> = ({
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<boolean>(false);
const [peerConnected, setPeerConnected] = useState<boolean>(false);
const [peerPubKey, setPeerPubKey] = useState<string>();
@ -268,7 +273,7 @@ const EncryptedSocketChat: React.FC<Props> = ({
/>
<Grid item>
<ChatHeader
connected={connected}
connected={connected && (peerPubKey ? true : false)}
peerConnected={peerConnected}
turtleMode={turtleMode}
setTurtleMode={setTurtleMode}

View File

@ -28,6 +28,11 @@ interface Props {
setTurtleMode: (state: boolean) => void;
}
const audioPath =
window.NativeRobosats === undefined
? '/static/assets/sounds'
: 'file:///android_asset/Web.bundle/assets/sounds';
const EncryptedTurtleChat: React.FC<Props> = ({
orderId,
robot,
@ -43,7 +48,7 @@ const EncryptedTurtleChat: React.FC<Props> = ({
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<boolean>(false);
const [peerPubKey, setPeerPubKey] = useState<string>();
const [value, setValue] = useState<string>('');
@ -255,7 +260,7 @@ const EncryptedTurtleChat: React.FC<Props> = ({
<Grid item>
<ChatHeader
connected={true}
connected={peerPubKey ? true : false}
peerConnected={peerConnected}
turtleMode={turtleMode}
setTurtleMode={setTurtleMode}