diff --git a/frontend/src/components/TradeBox/EncryptedChat/index.tsx b/frontend/src/components/TradeBox/EncryptedChat/index.tsx index 53041e7f..515a0d82 100644 --- a/frontend/src/components/TradeBox/EncryptedChat/index.tsx +++ b/frontend/src/components/TradeBox/EncryptedChat/index.tsx @@ -28,21 +28,13 @@ import CircularProgress from '@mui/material/CircularProgress'; import KeyIcon from '@mui/icons-material/Key'; import { ExportIcon } from '../../Icons'; import { useTheme } from '@mui/system'; +import { WebSocketsChatMessage } from '../../../models'; interface Props { orderId: number; userNick: string; } -interface EncryptedChatMessage { - userNick: string; - validSignature: boolean; - plainTextMessage: string; - encryptedMessage: string; - time: string; - index: number; -} - const EncryptedChat: React.FC = ({ orderId, userNick }: Props): JSX.Element => { const { t } = useTranslation(); const theme = useTheme(); @@ -58,7 +50,7 @@ const EncryptedChat: React.FC = ({ orderId, userNick }: Props): JSX.Eleme ); const [peerPubKey, setPeerPubKey] = useState(); const [token] = useState(systemClient.getCookie('robot_token') || ''); - const [messages, setMessages] = useState([]); + const [messages, setMessages] = useState([]); const [serverMessages, setServerMessages] = useState([]); const [value, setValue] = useState(''); const [connection, setConnection] = useState(); diff --git a/frontend/src/models/Chat.model.ts b/frontend/src/models/Chat.model.ts new file mode 100644 index 00000000..9d5f9ddb --- /dev/null +++ b/frontend/src/models/Chat.model.ts @@ -0,0 +1,23 @@ +export interface WebSocketsChatMessage { + userNick: string; + validSignature: boolean; + plainTextMessage: string; + encryptedMessage: string; + time: Date; + index: number; +} + +export interface APIChatMessage { + nick: string; + time: Date; + message: string; + index: number; +} + +export interface APIChat { + peer_pubkey: string; + peer_connected: boolean; + messages: APIChatMessage[]; +} + +export default APIChat; diff --git a/frontend/src/models/Order.model.ts b/frontend/src/models/Order.model.ts index f47de004..4819091c 100644 --- a/frontend/src/models/Order.model.ts +++ b/frontend/src/models/Order.model.ts @@ -1,3 +1,5 @@ +import { APIChat } from '.'; + export interface TradeRobotSummary { sent_fiat: number; received_sats: number; @@ -83,6 +85,7 @@ export interface Order { trade_fee_percent: number; bond_size_sats: number; bond_size_percent: number; + chat: APIChat; maker_summary: TradeRobotSummary; taker_summary: TradeRobotSummary; platform_summary: TradeCoordinatorSummary; diff --git a/frontend/src/models/index.ts b/frontend/src/models/index.ts index d9264c7e..9dc67c3e 100644 --- a/frontend/src/models/index.ts +++ b/frontend/src/models/index.ts @@ -1,4 +1,5 @@ import Robot from './Robot.model'; +export { Robot }; export type { LimitList } from './Limit.model'; export type { Limit } from './Limit.model'; @@ -11,8 +12,7 @@ export type { Settings } from './Settings.model'; export type { Language } from './Settings.model'; export type { Favorites } from './Favorites.model'; export type { Coordinator } from './Coordinator.model'; -export type { Maker } from './Maker.model'; -export { Robot }; +export type { APIChat, WebSocketsChatMessage, APIChatMessage } from './Chat.model'; export { defaultMaker } from './Maker.model'; export { defaultSettings } from './Settings.default.basic';