From 0b71537ff0e117f6845fd9294fa9df34f483c6bb Mon Sep 17 00:00:00 2001 From: nickago Date: Mon, 6 Jul 2015 08:14:42 -0700 Subject: Typing notifier resets on channel change --- web/react/components/msg_typing.jsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'web/react/components/msg_typing.jsx') diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index 9d3904757..3b97fb2ef 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() { + this.setState({text:""}) }, - _onChange: function(msg) { + _onSocketChange: function(msg) { if (msg.action == "typing" && this.props.channelId == msg.channel_id && this.props.parentId == msg.props.parent_id) { -- cgit v1.2.3-1-g7c22 From 8ac5f2233750c621099abb51006bf6fb0adbbf74 Mon Sep 17 00:00:00 2001 From: nickago Date: Mon, 6 Jul 2015 08:43:45 -0700 Subject: Typing notification disappears when message is sent --- web/react/components/msg_typing.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'web/react/components/msg_typing.jsx') diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index 3b97fb2ef..089412229 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: "" }; -- cgit v1.2.3-1-g7c22 From 83e4d3fb9cd2692a0363f48e70a50989b3e9a163 Mon Sep 17 00:00:00 2001 From: nickago Date: Mon, 6 Jul 2015 12:37:42 -0700 Subject: Changed socket event to a props based change --- web/react/components/msg_typing.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'web/react/components/msg_typing.jsx') diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx index 089412229..a6953028f 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); }, - componentWillUnmount: function() { - ChannelStore.removeDiffChannelChangeListener(this._onChange); - SocketStore.removeChangeListener(this._onSocketChange); + componentWillReceiveProps: function(newProps) { + if(this.props.channelId !== newProps.channelId) { + this.setState({text:""}); + } }, - _onChange: function() { - this.setState({text:""}) + componentWillUnmount: function() { + SocketStore.removeChangeListener(this._onChange); }, - _onSocketChange: function(msg) { + _onChange: function(msg) { if (msg.action == "typing" && this.props.channelId == msg.channel_id && this.props.parentId == msg.props.parent_id) { -- cgit v1.2.3-1-g7c22