aboutsummaryrefslogtreecommitdiff
path: root/src/Chat.js
diff options
context:
space:
mode:
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"
);