From 14c7bb1b4ac88296682b5845f348877979916792 Mon Sep 17 00:00:00 2001 From: osmarks Date: Fri, 5 Oct 2018 21:43:38 +0100 Subject: [PATCH] Fix typing in messages while messages are sent --- src/index.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/index.html b/src/index.html index 33eb72a..51db9b6 100644 --- a/src/index.html +++ b/src/index.html @@ -39,8 +39,7 @@ const state = { messages: [], websocket: null, URL: (window.location.href + "connect").replace("http", "ws"), - channel: "default", - message: "" + channel: "default" }; let windowVisible = true; @@ -140,17 +139,16 @@ const actions = { }); }, msgInput: event => (state, actions) => { - let val = event.target.value; if (event.keyCode == 13) { // enter key + let val = event.target.value; const channel = state.channel; actions.sendMessage([channel, val]); actions.normalMessage(["user", { channel, message: val }]); - val = ""; + event.target.value = ""; } - return { message: val }; }, channelInput: event => (state, actions) => { return { channel: event.target.value }; @@ -179,7 +177,7 @@ const view = (state, actions) => h.div([ ]), h.ul({class: "messages", onupdate: (element, old) => scrollDown()}, state.messages.map(viewMessage)), h.input({ onkeyup: actions.channelInput, placeholder: "Channel", value: state.channel }), - h.input({ onkeyup: actions.msgInput, placeholder: "Message", value: state.message }), + h.input({ onkeyup: actions.msgInput, placeholder: "Message" }), ]); const main = hyperapp.app(state, actions, view, document.getElementById("app"));