diff --git a/client/src/js/components/MessageInput.jsx b/client/src/js/components/MessageInput.jsx index 67bc3f5a..0505ca2d 100644 --- a/client/src/js/components/MessageInput.jsx +++ b/client/src/js/components/MessageInput.jsx @@ -48,6 +48,8 @@ var MessageInput = React.createClass({ inputHistoryActions.increment(); } else if (e.which === 40) { inputHistoryActions.decrement(); + } else if (e.key === 'Backspace' || e.key === 'Delete') { + inputHistoryActions.reset(); } else if (e.key === 'Unidentified') { inputHistoryActions.reset(); } diff --git a/client/src/js/socket.js b/client/src/js/socket.js index ee5b0152..323eaaf7 100644 --- a/client/src/js/socket.js +++ b/client/src/js/socket.js @@ -2,6 +2,8 @@ var EventEmitter = require('events').EventEmitter; var _ = require('lodash'); +var ws = new WebSocket('ws://' + window.location.host + '/ws'); + var socket = { send: function(type, data) { ws.send(JSON.stringify({ type: type, request: data })); @@ -10,8 +12,6 @@ var socket = { _.extend(socket, EventEmitter.prototype); -var ws = new WebSocket('ws://' + window.location.host + '/ws'); - ws.onopen = function() { socket.emit('connect'); }; diff --git a/client/src/js/stores/inputHistory.js b/client/src/js/stores/inputHistory.js index 462d344f..2377b45c 100644 --- a/client/src/js/stores/inputHistory.js +++ b/client/src/js/stores/inputHistory.js @@ -31,8 +31,10 @@ var inputHistoryStore = Reflux.createStore({ }, reset: function() { - index = -1; - this.trigger(history[index]); + if (index !== -1) { + index = -1; + this.trigger(history[index]); + } }, increment: function() { diff --git a/storage/user.go b/storage/user.go index 2b5d4050..c30c2cf8 100644 --- a/storage/user.go +++ b/storage/user.go @@ -20,7 +20,7 @@ type Server struct { type Channel struct { Server string `json:"server"` Name string `json:"name"` - Users []string `json:"users"` + Users []string `json:"users,omitempty"` Topic string `json:"topic,omitempty"` }