Add chat models

This commit is contained in:
Reckless_Satoshi 2022-11-01 11:29:48 -07:00
parent 4473923286
commit fa8f31981e
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
4 changed files with 30 additions and 12 deletions

View File

@ -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<Props> = ({ orderId, userNick }: Props): JSX.Element => {
const { t } = useTranslation();
const theme = useTheme();
@ -58,7 +50,7 @@ const EncryptedChat: React.FC<Props> = ({ orderId, userNick }: Props): JSX.Eleme
);
const [peerPubKey, setPeerPubKey] = useState<string>();
const [token] = useState<string>(systemClient.getCookie('robot_token') || '');
const [messages, setMessages] = useState<EncryptedChatMessage[]>([]);
const [messages, setMessages] = useState<WebSocketsChatMessage[]>([]);
const [serverMessages, setServerMessages] = useState<any[]>([]);
const [value, setValue] = useState<string>('');
const [connection, setConnection] = useState<WebsocketConnection>();

View File

@ -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;

View File

@ -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;

View File

@ -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';