From 0b71537ff0e117f6845fd9294fa9df34f483c6bb Mon Sep 17 00:00:00 2001 From: nickago Date: Mon, 6 Jul 2015 08:14:42 -0700 Subject: [PATCH 1/4] Typing notifier resets on channel change --- web/react/components/msg_typing.jsx | 13 +++++++++---- web/react/stores/channel_store.jsx | 13 +++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index 9d3904757f..3b97fb2efa 100644 --- a/web/react/components/msg_typing.jsx +++ b/web/react/components/msg_typing.jsx @@ -1,7 +1,7 @@ // Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. - +var ChannelStore = require('../stores/channel_store.jsx'); var SocketStore = require('../stores/socket_store.jsx'); var UserStore = require('../stores/user_store.jsx'); @@ -9,12 +9,17 @@ module.exports = React.createClass({ timer: null, lastTime: 0, componentDidMount: function() { - SocketStore.addChangeListener(this._onChange); + ChannelStore.addDiffChannelChangeListener(this._onChange); + SocketStore.addChangeListener(this._onSocketChange); }, componentWillUnmount: function() { - SocketStore.removeChangeListener(this._onChange); + ChannelStore.removeDiffCHannelChangeListener(this._onChange); + SocketStore.removeChangeListener(this._onSocketChange); }, - _onChange: function(msg) { + _onChange: function() { + this.setState({text:""}) + }, + _onSocketChange: function(msg) { if (msg.action == "typing" && this.props.channelId == msg.channel_id && this.props.parentId == msg.props.parent_id) { diff --git a/web/react/stores/channel_store.jsx b/web/react/stores/channel_store.jsx index 3f259bc7db..3713999a6c 100644 --- a/web/react/stores/channel_store.jsx +++ b/web/react/stores/channel_store.jsx @@ -12,6 +12,7 @@ var ActionTypes = Constants.ActionTypes; var CHANGE_EVENT = 'change'; var MORE_CHANGE_EVENT = 'change'; var EXTRA_INFO_EVENT = 'extra_info'; +var DIFF_CHANNEL_EVENT = 'change_channel'; var ChannelStore = assign({}, EventEmitter.prototype, { emitChange: function() { @@ -23,6 +24,15 @@ var ChannelStore = assign({}, EventEmitter.prototype, { removeChangeListener: function(callback) { this.removeListener(CHANGE_EVENT, callback); }, + emitDiffChannelChange: function() { + this.emit(DIFF_CHANNEL_EVENT); + }, + addDiffChannelChangeListener: function(callback) { + this.on(DIFF_CHANNEL_EVENT,callback); + }, + removeDiffChannelChangeListener: function(callback) { + this.removeListener(DIFF_CHANNEL_EVENT,callback); + }, emitMoreChange: function() { this.emit(MORE_CHANGE_EVENT); }, @@ -218,6 +228,8 @@ var ChannelStore = assign({}, EventEmitter.prototype, { ChannelStore.dispatchToken = AppDispatcher.register(function(payload) { var action = payload.action; + //console.log(payload); + //console.log(action.type + " " + (action.msg ? action.msg.action : "")) switch(action.type) { @@ -225,6 +237,7 @@ ChannelStore.dispatchToken = AppDispatcher.register(function(payload) { ChannelStore.setCurrentId(action.id); ChannelStore.setLastVisitedName(action.name); ChannelStore.resetCounts(action.id); + ChannelStore.emitDiffChannelChange(); ChannelStore.emitChange(); break; From 8ac5f2233750c621099abb51006bf6fb0adbbf74 Mon Sep 17 00:00:00 2001 From: nickago Date: Mon, 6 Jul 2015 08:43:45 -0700 Subject: [PATCH 2/4] Typing notification disappears when message is sent --- web/react/components/msg_typing.jsx | 5 ++++- web/react/stores/channel_store.jsx | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index 3b97fb2efa..0894122291 100644 --- a/web/react/components/msg_typing.jsx +++ b/web/react/components/msg_typing.jsx @@ -13,7 +13,7 @@ module.exports = React.createClass({ SocketStore.addChangeListener(this._onSocketChange); }, componentWillUnmount: function() { - ChannelStore.removeDiffCHannelChangeListener(this._onChange); + ChannelStore.removeDiffChannelChangeListener(this._onChange); SocketStore.removeChangeListener(this._onSocketChange); }, _onChange: function() { @@ -42,6 +42,9 @@ module.exports = React.createClass({ }, 3000); } } + else if (msg.action == "posted" && msg.channel_id === this.props.channelId) { + this.setState({text:""}) + } }, getInitialState: function() { return { text: "" }; diff --git a/web/react/stores/channel_store.jsx b/web/react/stores/channel_store.jsx index 3713999a6c..4e52cccd37 100644 --- a/web/react/stores/channel_store.jsx +++ b/web/react/stores/channel_store.jsx @@ -228,8 +228,6 @@ var ChannelStore = assign({}, EventEmitter.prototype, { ChannelStore.dispatchToken = AppDispatcher.register(function(payload) { var action = payload.action; - //console.log(payload); - //console.log(action.type + " " + (action.msg ? action.msg.action : "")) switch(action.type) { From 83e4d3fb9cd2692a0363f48e70a50989b3e9a163 Mon Sep 17 00:00:00 2001 From: nickago Date: Mon, 6 Jul 2015 12:37:42 -0700 Subject: [PATCH 3/4] Changed socket event to a props based change --- web/react/components/msg_typing.jsx | 18 +++++++++--------- web/react/stores/channel_store.jsx | 11 ----------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index 0894122291..a6953028f1 100644 --- a/web/react/components/msg_typing.jsx +++ b/web/react/components/msg_typing.jsx @@ -1,7 +1,7 @@ // Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // See License.txt for license information. -var ChannelStore = require('../stores/channel_store.jsx'); + var SocketStore = require('../stores/socket_store.jsx'); var UserStore = require('../stores/user_store.jsx'); @@ -9,17 +9,17 @@ module.exports = React.createClass({ timer: null, lastTime: 0, componentDidMount: function() { - ChannelStore.addDiffChannelChangeListener(this._onChange); - SocketStore.addChangeListener(this._onSocketChange); + SocketStore.addChangeListener(this._onChange); + }, + componentWillReceiveProps: function(newProps) { + if(this.props.channelId !== newProps.channelId) { + this.setState({text:""}); + } }, componentWillUnmount: function() { - ChannelStore.removeDiffChannelChangeListener(this._onChange); - SocketStore.removeChangeListener(this._onSocketChange); + SocketStore.removeChangeListener(this._onChange); }, - _onChange: function() { - this.setState({text:""}) - }, - _onSocketChange: function(msg) { + _onChange: function(msg) { if (msg.action == "typing" && this.props.channelId == msg.channel_id && this.props.parentId == msg.props.parent_id) { diff --git a/web/react/stores/channel_store.jsx b/web/react/stores/channel_store.jsx index 4e52cccd37..3f259bc7db 100644 --- a/web/react/stores/channel_store.jsx +++ b/web/react/stores/channel_store.jsx @@ -12,7 +12,6 @@ var ActionTypes = Constants.ActionTypes; var CHANGE_EVENT = 'change'; var MORE_CHANGE_EVENT = 'change'; var EXTRA_INFO_EVENT = 'extra_info'; -var DIFF_CHANNEL_EVENT = 'change_channel'; var ChannelStore = assign({}, EventEmitter.prototype, { emitChange: function() { @@ -24,15 +23,6 @@ var ChannelStore = assign({}, EventEmitter.prototype, { removeChangeListener: function(callback) { this.removeListener(CHANGE_EVENT, callback); }, - emitDiffChannelChange: function() { - this.emit(DIFF_CHANNEL_EVENT); - }, - addDiffChannelChangeListener: function(callback) { - this.on(DIFF_CHANNEL_EVENT,callback); - }, - removeDiffChannelChangeListener: function(callback) { - this.removeListener(DIFF_CHANNEL_EVENT,callback); - }, emitMoreChange: function() { this.emit(MORE_CHANGE_EVENT); }, @@ -235,7 +225,6 @@ ChannelStore.dispatchToken = AppDispatcher.register(function(payload) { ChannelStore.setCurrentId(action.id); ChannelStore.setLastVisitedName(action.name); ChannelStore.resetCounts(action.id); - ChannelStore.emitDiffChannelChange(); ChannelStore.emitChange(); break; From 122a67c3b45548bd0d091a398c8d7c2a884681e6 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 6 Jul 2015 18:08:52 -0400 Subject: [PATCH 4/4] Explicitly cast to an int64 when selecting a random profile picture colour to prevent overflow on 32-bit installations of Go --- api/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/user.go b/api/user.go index 292d2b61b7..ada781bc7d 100644 --- a/api/user.go +++ b/api/user.go @@ -593,7 +593,7 @@ func createProfileImage(username string, userId string) ([]byte, *model.AppError h.Write([]byte(userId)) seed := h.Sum32() - color := colors[int(seed)%len(colors)] + color := colors[int64(seed)%int64(len(colors))] img := image.NewRGBA(image.Rect(0, 0, int(utils.Cfg.ImageSettings.ProfileWidth), int(utils.Cfg.ImageSettings.ProfileHeight))) draw.Draw(img, img.Bounds(), &image.Uniform{color}, image.ZP, draw.Src)