mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-11 00:31:34 +00:00
Add chat models
This commit is contained in:
parent
4473923286
commit
fa8f31981e
@ -28,21 +28,13 @@ import CircularProgress from '@mui/material/CircularProgress';
|
|||||||
import KeyIcon from '@mui/icons-material/Key';
|
import KeyIcon from '@mui/icons-material/Key';
|
||||||
import { ExportIcon } from '../../Icons';
|
import { ExportIcon } from '../../Icons';
|
||||||
import { useTheme } from '@mui/system';
|
import { useTheme } from '@mui/system';
|
||||||
|
import { WebSocketsChatMessage } from '../../../models';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
orderId: number;
|
orderId: number;
|
||||||
userNick: string;
|
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 EncryptedChat: React.FC<Props> = ({ orderId, userNick }: Props): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@ -58,7 +50,7 @@ const EncryptedChat: React.FC<Props> = ({ orderId, userNick }: Props): JSX.Eleme
|
|||||||
);
|
);
|
||||||
const [peerPubKey, setPeerPubKey] = useState<string>();
|
const [peerPubKey, setPeerPubKey] = useState<string>();
|
||||||
const [token] = useState<string>(systemClient.getCookie('robot_token') || '');
|
const [token] = useState<string>(systemClient.getCookie('robot_token') || '');
|
||||||
const [messages, setMessages] = useState<EncryptedChatMessage[]>([]);
|
const [messages, setMessages] = useState<WebSocketsChatMessage[]>([]);
|
||||||
const [serverMessages, setServerMessages] = useState<any[]>([]);
|
const [serverMessages, setServerMessages] = useState<any[]>([]);
|
||||||
const [value, setValue] = useState<string>('');
|
const [value, setValue] = useState<string>('');
|
||||||
const [connection, setConnection] = useState<WebsocketConnection>();
|
const [connection, setConnection] = useState<WebsocketConnection>();
|
||||||
|
23
frontend/src/models/Chat.model.ts
Normal file
23
frontend/src/models/Chat.model.ts
Normal 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;
|
@ -1,3 +1,5 @@
|
|||||||
|
import { APIChat } from '.';
|
||||||
|
|
||||||
export interface TradeRobotSummary {
|
export interface TradeRobotSummary {
|
||||||
sent_fiat: number;
|
sent_fiat: number;
|
||||||
received_sats: number;
|
received_sats: number;
|
||||||
@ -83,6 +85,7 @@ export interface Order {
|
|||||||
trade_fee_percent: number;
|
trade_fee_percent: number;
|
||||||
bond_size_sats: number;
|
bond_size_sats: number;
|
||||||
bond_size_percent: number;
|
bond_size_percent: number;
|
||||||
|
chat: APIChat;
|
||||||
maker_summary: TradeRobotSummary;
|
maker_summary: TradeRobotSummary;
|
||||||
taker_summary: TradeRobotSummary;
|
taker_summary: TradeRobotSummary;
|
||||||
platform_summary: TradeCoordinatorSummary;
|
platform_summary: TradeCoordinatorSummary;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Robot from './Robot.model';
|
import Robot from './Robot.model';
|
||||||
|
export { Robot };
|
||||||
|
|
||||||
export type { LimitList } from './Limit.model';
|
export type { LimitList } from './Limit.model';
|
||||||
export type { Limit } 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 { Language } from './Settings.model';
|
||||||
export type { Favorites } from './Favorites.model';
|
export type { Favorites } from './Favorites.model';
|
||||||
export type { Coordinator } from './Coordinator.model';
|
export type { Coordinator } from './Coordinator.model';
|
||||||
export type { Maker } from './Maker.model';
|
export type { APIChat, WebSocketsChatMessage, APIChatMessage } from './Chat.model';
|
||||||
export { Robot };
|
|
||||||
|
|
||||||
export { defaultMaker } from './Maker.model';
|
export { defaultMaker } from './Maker.model';
|
||||||
export { defaultSettings } from './Settings.default.basic';
|
export { defaultSettings } from './Settings.default.basic';
|
||||||
|
Loading…
Reference in New Issue
Block a user