Make ChatTitle and UserList render functions pure
This commit is contained in:
parent
f497e248f1
commit
d4d51778fb
@ -100,7 +100,7 @@ gulp.task('bindata', ['gzip'], function(cb) {
|
|||||||
gulp.task('gzip:watch', function() {
|
gulp.task('gzip:watch', function() {
|
||||||
return gulp.src('dist/**/*.{html,css,js}')
|
return gulp.src('dist/**/*.{html,css,js}')
|
||||||
.pipe(gzip())
|
.pipe(gzip())
|
||||||
.pipe(gulp.dest('dist'));
|
.pipe(gulp.dest('dist/gz'));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('bindata:watch', ['gzip:watch'], function(cb) {
|
gulp.task('bindata:watch', ['gzip:watch'], function(cb) {
|
||||||
|
@ -10,17 +10,25 @@ var privateChatActions = require('../actions/privateChat');
|
|||||||
|
|
||||||
var ChatTitle = React.createClass({
|
var ChatTitle = React.createClass({
|
||||||
mixins: [
|
mixins: [
|
||||||
Reflux.connect(channelStore, 'channels'),
|
Reflux.listenTo(channelStore, 'channelsChanged'),
|
||||||
Reflux.connect(selectedTabStore, 'selectedTab')
|
Reflux.connect(selectedTabStore, 'selectedTab')
|
||||||
],
|
],
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
var tab = selectedTabStore.getState();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
channels: channelStore.getState(),
|
usercount: channelStore.getUsers(tab.server, tab.channel).length,
|
||||||
selectedTab: selectedTabStore.getState()
|
selectedTab: tab
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
channelsChanged: function() {
|
||||||
|
var tab = this.state.selectedTab;
|
||||||
|
|
||||||
|
this.setState({ usercount: channelStore.getUsers(tab.server, tab.channel).length });
|
||||||
|
},
|
||||||
|
|
||||||
handleLeaveClick: function() {
|
handleLeaveClick: function() {
|
||||||
var tab = this.state.selectedTab;
|
var tab = this.state.selectedTab;
|
||||||
|
|
||||||
@ -35,7 +43,6 @@ var ChatTitle = React.createClass({
|
|||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var tab = this.state.selectedTab;
|
var tab = this.state.selectedTab;
|
||||||
var usercount = channelStore.getUsers(tab.server, tab.channel).length;
|
|
||||||
var leaveTitle;
|
var leaveTitle;
|
||||||
|
|
||||||
if (!tab.channel) {
|
if (!tab.channel) {
|
||||||
@ -58,7 +65,7 @@ var ChatTitle = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
<div className="userlist-bar">
|
<div className="userlist-bar">
|
||||||
<i className="icon-user"></i>
|
<i className="icon-user"></i>
|
||||||
<span className="chat-usercount">{usercount || null}</span>
|
<span className="chat-usercount">{this.state.usercount || null}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -9,14 +9,16 @@ var selectedTabStore = require('../stores/selectedTab');
|
|||||||
|
|
||||||
var UserList = React.createClass({
|
var UserList = React.createClass({
|
||||||
mixins: [
|
mixins: [
|
||||||
Reflux.connect(channelStore, 'channels'),
|
Reflux.listenTo(channelStore, 'channelsChanged'),
|
||||||
Reflux.connect(selectedTabStore, 'selectedTab')
|
Reflux.connect(selectedTabStore, 'selectedTab')
|
||||||
],
|
],
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
var tab = selectedTabStore.getState();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
channels: channelStore.getState(),
|
users: channelStore.getUsers(tab.server, tab.channel),
|
||||||
selectedTab: selectedTabStore.getState(),
|
selectedTab: tab,
|
||||||
height: window.innerHeight - 100
|
height: window.innerHeight - 100
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -29,19 +31,25 @@ var UserList = React.createClass({
|
|||||||
window.removeEventListener('resize', this.handleResize);
|
window.removeEventListener('resize', this.handleResize);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
channelsChanged: function() {
|
||||||
|
var tab = this.state.selectedTab;
|
||||||
|
|
||||||
|
this.setState({ users: channelStore.getUsers(tab.server, tab.channel) });
|
||||||
|
},
|
||||||
|
|
||||||
handleResize: function() {
|
handleResize: function() {
|
||||||
this.setState({ height: window.innerHeight - 100 });
|
this.setState({ height: window.innerHeight - 100 });
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var users = [];
|
|
||||||
var tab = this.state.selectedTab;
|
var tab = this.state.selectedTab;
|
||||||
|
var users = [];
|
||||||
var style = {};
|
var style = {};
|
||||||
|
|
||||||
if (!tab.channel || tab.channel[0] !== '#') {
|
if (!tab.channel || tab.channel[0] !== '#') {
|
||||||
style.display = 'none';
|
style.display = 'none';
|
||||||
} else {
|
} else {
|
||||||
users = _.map(channelStore.getUsers(tab.server, tab.channel), (user) => {
|
users = _.map(this.state.users, (user) => {
|
||||||
return <UserListItem key={user.nick} user={user} />;
|
return <UserListItem key={user.nick} user={user} />;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user