aboutsummaryrefslogtreecommitdiff
path: root/src/Chat.js
diff options
context:
space:
mode:
authorLibravatar Renard 2020-03-12 01:22:29 -0300
committerLibravatar Renard 2020-03-12 01:22:29 -0300
commit41e8379fb66c12d5468bda329560fd9c66c066cf (patch)
treef5711f921df7b70d52d643d1c91c3762b366f876 /src/Chat.js
parent4c109a9bb8c9a158b3d2f18f3216ce95d52e2ae8 (diff)
downloadbairadio-app-41e8379fb66c12d5468bda329560fd9c66c066cf.tar.gz
bairadio-app-41e8379fb66c12d5468bda329560fd9c66c066cf.tar.xz
bairadio-app-41e8379fb66c12d5468bda329560fd9c66c066cf.zip
printMessage()
Diffstat (limited to 'src/Chat.js')
-rw-r--r--src/Chat.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/Chat.js b/src/Chat.js
index 701d0a2..6840415 100644
--- a/src/Chat.js
+++ b/src/Chat.js
@@ -47,13 +47,7 @@ class Chat extends Component {
color = "grey",
timestamp = ""
) {
- let ts;
- if (timestamp) {
- ts = new Date(parseInt(timestamp));
- console.log(ts);
- } else {
- ts = new Date();
- }
+ const ts = timestamp ? new Date(parseInt(timestamp)) : new Date();
this.setState(
prevState => ({
chat: [
@@ -77,6 +71,10 @@ class Chat extends Component {
);
}
+ printMessage(message, color) {
+ this.addMessage(message, "", false, "", color);
+ }
+
componentWillMount() {
this.client = new W3CWebSocket(
"wss://radio.bienvenidoainternet.org/daemon/"
@@ -89,7 +87,7 @@ class Chat extends Component {
};
this.client.onerror = () => {
this.setState({ isChatOnline: false });
- this.addMessage("Ha ocurrido un error conectándose al chat.", "red");
+ this.printMessage("Ha ocurrido un error conectándose al chat.", "red");
};
}
@@ -131,14 +129,14 @@ class Chat extends Component {
);
break;
case "WELCOME":
- this.addMessage("Conectado al chat, " + args[1], "", false, "green");
+ this.printMessage("Conectado al chat, " + args[1], "green");
this.client.send("HISTORY:10");
break;
case "COUNT":
this.setState({ chatUserCount: args[1] });
break;
case "FLOOD":
- this.addMessage(
+ this.printMessage(
"Error: Estas enviando mensajes demasido rápido!",
"red"
);