Move messaging components to single component

This commit is contained in:
Franck Royer 2021-06-29 15:53:59 +10:00
parent 5bc0eddd3a
commit a46a05a5ea
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 38 additions and 10 deletions

View File

@ -6,15 +6,9 @@ import { Waku } from 'js-waku';
import { ethers } from 'ethers';
import { Web3Provider } from '@ethersproject/providers';
import { KeyPair } from './crypto';
import Messages, { Message } from './messaging/Messages';
import { Message } from './messaging/Messages';
import 'fontsource-roboto';
import {
AppBar,
IconButton,
Toolbar,
Typography,
} from '@material-ui/core';
import SendMessage from './messaging/SendMessage';
import { AppBar, IconButton, Toolbar, Typography } from '@material-ui/core';
import KeyPairHandling from './key_pair_handling/KeyPairHandling';
import InitWaku from './InitWaku';
import {
@ -25,6 +19,7 @@ import {
import { teal, purple, green } from '@material-ui/core/colors';
import WifiIcon from '@material-ui/icons/Wifi';
import BroadcastPublicKey from './BroadcastPublicKey';
import Messaging from './messaging/Messaging';
declare let window: any;
@ -131,8 +126,11 @@ function App() {
</fieldset>
<fieldset>
<legend>Messaging</legend>
<SendMessage recipients={publicKeys} waku={waku} />
<Messages messages={messages} />
<Messaging
recipients={publicKeys}
waku={waku}
messages={messages}
/>
</fieldset>
</main>
</div>

View File

@ -0,0 +1,30 @@
import Messages, { Message } from './Messages';
import { Waku } from 'js-waku';
import SendMessage from './SendMessage';
import { makeStyles } from '@material-ui/core';
const useStyles = makeStyles({
root: {
display: 'flex',
alignItems: 'left',
flexDirection: 'column',
margin: '5px',
},
});
interface Props {
waku: Waku | undefined;
recipients: Map<string, string>;
messages: Message[];
}
export default function Messaging({ waku, recipients, messages }: Props) {
const classes = useStyles();
return (
<div className={classes.root}>
<SendMessage recipients={recipients} waku={waku} />
<Messages messages={messages} />
</div>
);
}