mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-07 18:04:07 +00:00
@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { Button, TextField, Grid, Paper, Typography } from '@mui/material';
|
import { Button, TextField, Grid, Paper, Typography } from '@mui/material';
|
||||||
import { encryptMessage, decryptMessage } from '../../../../pgp';
|
import { encryptMessage, decryptMessage } from '../../../../pgp';
|
||||||
import { AuditPGPDialog } from '../../../Dialogs';
|
import { AuditPGPDialog } from '../../../Dialogs';
|
||||||
import { websocketClient, type WebsocketConnection } from '../../../../services/Websocket';
|
|
||||||
import { GarageContext, type UseGarageStoreType } from '../../../../contexts/GarageContext';
|
import { GarageContext, type UseGarageStoreType } from '../../../../contexts/GarageContext';
|
||||||
|
|
||||||
// Icons
|
// Icons
|
||||||
@ -21,6 +20,7 @@ import {
|
|||||||
FederationContext,
|
FederationContext,
|
||||||
} from '../../../../contexts/FederationContext';
|
} from '../../../../contexts/FederationContext';
|
||||||
import { type UseAppStoreType, AppContext } from '../../../../contexts/AppContext';
|
import { type UseAppStoreType, AppContext } from '../../../../contexts/AppContext';
|
||||||
|
import TorModule from '../../../../native/TorModule';
|
||||||
|
|
||||||
const audioPath =
|
const audioPath =
|
||||||
window.NativeRobosats === undefined
|
window.NativeRobosats === undefined
|
||||||
@ -64,7 +64,7 @@ const EncryptedSocketChat: React.FC<Props> = ({
|
|||||||
const [peerPubKey, setPeerPubKey] = useState<string>();
|
const [peerPubKey, setPeerPubKey] = useState<string>();
|
||||||
const [serverMessages, setServerMessages] = useState<ServerMessage[]>([]);
|
const [serverMessages, setServerMessages] = useState<ServerMessage[]>([]);
|
||||||
const [value, setValue] = useState<string>('');
|
const [value, setValue] = useState<string>('');
|
||||||
const [connection, setConnection] = useState<WebsocketConnection>();
|
const [connection, setConnection] = useState<WebSocket | null>(null);
|
||||||
const [audit, setAudit] = useState<boolean>(false);
|
const [audit, setAudit] = useState<boolean>(false);
|
||||||
const [waitingEcho, setWaitingEcho] = useState<boolean>(false);
|
const [waitingEcho, setWaitingEcho] = useState<boolean>(false);
|
||||||
const [lastSent, setLastSent] = useState<string>('---BLANK---');
|
const [lastSent, setLastSent] = useState<string>('---BLANK---');
|
||||||
@ -82,7 +82,7 @@ const EncryptedSocketChat: React.FC<Props> = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (![9, 10].includes(status)) {
|
if (![9, 10].includes(status)) {
|
||||||
connection?.close();
|
connection?.close();
|
||||||
setConnection(undefined);
|
setConnection(null);
|
||||||
}
|
}
|
||||||
}, [status]);
|
}, [status]);
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ const EncryptedSocketChat: React.FC<Props> = ({
|
|||||||
// On component unmount close reconnecting-websockets
|
// On component unmount close reconnecting-websockets
|
||||||
return () => {
|
return () => {
|
||||||
connection?.close();
|
connection?.close();
|
||||||
setConnection(undefined);
|
setConnection(null);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -117,12 +117,11 @@ const EncryptedSocketChat: React.FC<Props> = ({
|
|||||||
.getCoordinator(order.shortAlias)
|
.getCoordinator(order.shortAlias)
|
||||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||||
|
|
||||||
websocketClient
|
TorModule.sendWsOpen(
|
||||||
.open(
|
`${url.replace(/^https?:\/\//, 'ws://') + basePath}/ws/chat/${
|
||||||
`${url.replace(/^https?:\/\//, 'ws://') + basePath}/ws/chat/${
|
order.id
|
||||||
order.id
|
}/?token_sha256_hex=${sha256(slot?.token)}`,
|
||||||
}/?token_sha256_hex=${sha256(slot?.token)}`,
|
)
|
||||||
)
|
|
||||||
.then((connection) => {
|
.then((connection) => {
|
||||||
setConnection(connection);
|
setConnection(connection);
|
||||||
setConnected(true);
|
setConnected(true);
|
||||||
|
Reference in New Issue
Block a user