mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Changed socket event to a props based change
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user