Fix state updating in ChatTitle and UserList

This commit is contained in:
khlieng 2015-05-16 22:25:22 +02:00
parent d4d51778fb
commit 77c723344c
3 changed files with 24 additions and 10 deletions

View File

@ -11,7 +11,7 @@ var privateChatActions = require('../actions/privateChat');
var ChatTitle = React.createClass({
mixins: [
Reflux.listenTo(channelStore, 'channelsChanged'),
Reflux.connect(selectedTabStore, 'selectedTab')
Reflux.listenTo(selectedTabStore, 'selectedTabChanged')
],
getInitialState: function() {
@ -29,6 +29,13 @@ var ChatTitle = React.createClass({
this.setState({ usercount: channelStore.getUsers(tab.server, tab.channel).length });
},
selectedTabChanged: function(tab) {
this.setState({
selectedTab: tab,
usercount: channelStore.getUsers(tab.server, tab.channel).length
});
},
handleLeaveClick: function() {
var tab = this.state.selectedTab;

View File

@ -10,7 +10,7 @@ var selectedTabStore = require('../stores/selectedTab');
var UserList = React.createClass({
mixins: [
Reflux.listenTo(channelStore, 'channelsChanged'),
Reflux.connect(selectedTabStore, 'selectedTab')
Reflux.listenTo(selectedTabStore, 'selectedTabChanged')
],
getInitialState: function() {
@ -37,6 +37,13 @@ var UserList = React.createClass({
this.setState({ users: channelStore.getUsers(tab.server, tab.channel) });
},
selectedTabChanged: function(tab) {
this.setState({
selectedTab: tab,
users: channelStore.getUsers(tab.server, tab.channel)
});
},
handleResize: function() {
this.setState({ height: window.innerHeight - 100 });
},

File diff suppressed because one or more lines are too long