Made backspace work on input history items

This commit is contained in:
khlieng 2015-02-12 02:14:56 +01:00
parent 8a790a6fe2
commit b7cafc5327
4 changed files with 9 additions and 5 deletions

View File

@ -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();
}

View File

@ -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');
};

View File

@ -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() {

View File

@ -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"`
}