let's wrap when you go off the beginning

This commit is contained in:
Matthew Hodgson 2015-08-14 15:51:57 +01:00
parent 960a38fe43
commit 316a28838f
2 changed files with 6 additions and 3 deletions

View file

@ -182,12 +182,12 @@ module.exports = {
var self = this;
setTimeout(function() {
if (self.refs.textarea.getDOMNode().value != '') {
if (self.refs.textarea && self.refs.textarea.getDOMNode().value != '') {
self.onTypingActivity();
} else {
self.onFinishedTyping();
}
}, 10);
}, 10); // XXX: what is this 10ms setTimeout doing? Looks hacky :(
},
onEnter: function(ev) {

View file

@ -166,7 +166,8 @@ module.exports = {
break;
}
}
roomIndex = Math.max((roomIndex + roomIndexDelta) % allRooms.length, 0);
roomIndex = (roomIndex + roomIndexDelta) % allRooms.length;
if (roomIndex < 0) roomIndex = allRooms.length - 1;
this.focusComposer = true;
this.setState({
currentRoom: allRooms[roomIndex].roomId
@ -250,10 +251,12 @@ module.exports = {
case 38:
dis.dispatch({action: 'view_prev_room'});
ev.stopPropagation();
ev.preventDefault();
break;
case 40:
dis.dispatch({action: 'view_next_room'});
ev.stopPropagation();
ev.preventDefault();
break;
}
}