Typing notifier resets on channel change
Этот коммит содержится в:
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
|
var ChannelStore = require('../stores/channel_store.jsx');
|
||||||
var SocketStore = require('../stores/socket_store.jsx');
|
var SocketStore = require('../stores/socket_store.jsx');
|
||||||
var UserStore = require('../stores/user_store.jsx');
|
var UserStore = require('../stores/user_store.jsx');
|
||||||
|
|
||||||
@@ -9,12 +9,17 @@ module.exports = React.createClass({
|
|||||||
timer: null,
|
timer: null,
|
||||||
lastTime: 0,
|
lastTime: 0,
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
SocketStore.addChangeListener(this._onChange);
|
ChannelStore.addDiffChannelChangeListener(this._onChange);
|
||||||
|
SocketStore.addChangeListener(this._onSocketChange);
|
||||||
},
|
},
|
||||||
componentWillUnmount: function() {
|
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" &&
|
if (msg.action == "typing" &&
|
||||||
this.props.channelId == msg.channel_id &&
|
this.props.channelId == msg.channel_id &&
|
||||||
this.props.parentId == msg.props.parent_id) {
|
this.props.parentId == msg.props.parent_id) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ var ActionTypes = Constants.ActionTypes;
|
|||||||
var CHANGE_EVENT = 'change';
|
var CHANGE_EVENT = 'change';
|
||||||
var MORE_CHANGE_EVENT = 'change';
|
var MORE_CHANGE_EVENT = 'change';
|
||||||
var EXTRA_INFO_EVENT = 'extra_info';
|
var EXTRA_INFO_EVENT = 'extra_info';
|
||||||
|
var DIFF_CHANNEL_EVENT = 'change_channel';
|
||||||
|
|
||||||
var ChannelStore = assign({}, EventEmitter.prototype, {
|
var ChannelStore = assign({}, EventEmitter.prototype, {
|
||||||
emitChange: function() {
|
emitChange: function() {
|
||||||
@@ -23,6 +24,15 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
|
|||||||
removeChangeListener: function(callback) {
|
removeChangeListener: function(callback) {
|
||||||
this.removeListener(CHANGE_EVENT, 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() {
|
emitMoreChange: function() {
|
||||||
this.emit(MORE_CHANGE_EVENT);
|
this.emit(MORE_CHANGE_EVENT);
|
||||||
},
|
},
|
||||||
@@ -218,6 +228,8 @@ var ChannelStore = assign({}, EventEmitter.prototype, {
|
|||||||
|
|
||||||
ChannelStore.dispatchToken = AppDispatcher.register(function(payload) {
|
ChannelStore.dispatchToken = AppDispatcher.register(function(payload) {
|
||||||
var action = payload.action;
|
var action = payload.action;
|
||||||
|
//console.log(payload);
|
||||||
|
//console.log(action.type + " " + (action.msg ? action.msg.action : ""))
|
||||||
|
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
|
|
||||||
@@ -225,6 +237,7 @@ ChannelStore.dispatchToken = AppDispatcher.register(function(payload) {
|
|||||||
ChannelStore.setCurrentId(action.id);
|
ChannelStore.setCurrentId(action.id);
|
||||||
ChannelStore.setLastVisitedName(action.name);
|
ChannelStore.setLastVisitedName(action.name);
|
||||||
ChannelStore.resetCounts(action.id);
|
ChannelStore.resetCounts(action.id);
|
||||||
|
ChannelStore.emitDiffChannelChange();
|
||||||
ChannelStore.emitChange();
|
ChannelStore.emitChange();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user