From d02b96af5e79d3656da20525ccdab1c2ec8ce5d0 Mon Sep 17 00:00:00 2001 From: Ines Guerrero Date: Thu, 17 Oct 2019 20:40:10 +0100 Subject: [PATCH] added validation for room name on index.js --- src/index.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/index.js b/src/index.js index 158ce6a..81e6b24 100644 --- a/src/index.js +++ b/src/index.js @@ -72,8 +72,12 @@ class View extends React.Component { hooks: { onMessage: this.actions.addMessage }, }), - createRoom: options => - this.state.user.createRoom(options).then(this.actions.joinRoom), + createRoom: options => { + // validation for room name + if (options.name.length > 0) { + this.state.user.createRoom(options).then(this.actions.joinRoom) + } + }, createConvo: options => { if (options.user.id !== this.state.user.id) { @@ -126,9 +130,9 @@ class View extends React.Component { ...prevState.messages, [roomId]: { ...prevState.messages[roomId], - [messageId]: payload - } - } + [messageId]: payload, + }, + }, })) // Update cursor if the message was read if (roomId === this.state.room.id) { @@ -170,9 +174,9 @@ class View extends React.Component { ...prevState.typing, [room.id]: { ...prevState.typing[room.id], - [user.id]: true - } - } + [user.id]: true, + }, + }, })), notTyping: (room, user) => @@ -181,9 +185,9 @@ class View extends React.Component { ...prevState.typing, [room.id]: { ...prevState.typing[room.id], - [user.id]: false - } - } + [user.id]: false, + }, + }, })), // --------------------------------------