Skip to content

Commit

Permalink
fix warnings & lints
Browse files Browse the repository at this point in the history
  • Loading branch information
SillyFreak committed Jun 21, 2020
1 parent 4f5e980 commit da37bb4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/routes/webrtc/WebRTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ type ChatProps = {|
sendText: string,
|};

function Chat({
connection,
sendText,
}: ChatProps) {
function Chat({ connection, sendText }: ChatProps) {
const [messages, setMessages] = React.useState<Message[]>([]);

function handleSend() {
Expand All @@ -50,13 +47,16 @@ function Chat({

return () => {
connection.off('data', handleRecv);
}
};
}, [connection]);

return (
<Paper className={s.chat} square>
{messages.map(({ type, text }) => (
<div className={`${s.msg} ${type === 'OUT' ? s.mine : s.theirs}`}>{text}</div>
{messages.map(({ type, text }, index) => (
// eslint-disable-next-line react/no-array-index-key
<div key={index} className={`${s.msg} ${type === 'OUT' ? s.mine : s.theirs}`}>
{text}
</div>
))}
<div>
<button type="button" onClick={handleSend}>
Expand All @@ -78,16 +78,22 @@ function WebRTC(_props: Props) {
(async () => {
const leftPeer = new Peer(peerOptions);
const rightPeer = new Peer(peerOptions);
// eslint-disable-next-line no-console
console.log('peers created');
// eslint-disable-next-line no-console
leftPeer.on('error', err => console.log(err));
// eslint-disable-next-line no-console
rightPeer.on('error', err => console.log(err));

const leftId = await new Promise(resolve => leftPeer.on('open', resolve));
// eslint-disable-next-line no-console
console.log(leftId);
await new Promise(resolve => setTimeout(resolve, 500));
// eslint-disable-next-line no-console
console.log('trying to connect...');
const rightConn = rightPeer.connect(leftId);
const leftConn = await new Promise(resolve => leftPeer.on('connection', resolve));
// eslint-disable-next-line no-console
console.log('peers connected');

setLeft(leftConn);
Expand Down

0 comments on commit da37bb4

Please sign in to comment.