Made state getter member function and fixed scu edge case
Этот коммит содержится в:
@@ -9,7 +9,22 @@ var utils = require('../utils/utils.jsx');
|
|||||||
var client = require('../utils/client.jsx');
|
var client = require('../utils/client.jsx');
|
||||||
var AsyncClient = require('../utils/async_client.jsx');
|
var AsyncClient = require('../utils/async_client.jsx');
|
||||||
|
|
||||||
function getStateFromStores() {
|
|
||||||
|
export default class ChannelInviteModal extends React.Component {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.componentDidMount = this.componentDidMount.bind(this);
|
||||||
|
this.componentWillUnmount = this.componentWillUnmount.bind(this);
|
||||||
|
this.onShow = this.onShow.bind(this);
|
||||||
|
this.onHide = this.onHide.bind(this);
|
||||||
|
this.onListenerChange = this.onListenerChange.bind(this);
|
||||||
|
this.handleInvite = this.handleInvite.bind(this);
|
||||||
|
|
||||||
|
this.isShown = false;
|
||||||
|
this.state = this.getStateFromStores();
|
||||||
|
}
|
||||||
|
getStateFromStores() {
|
||||||
function getId(user) {
|
function getId(user) {
|
||||||
return user.id;
|
return user.id;
|
||||||
}
|
}
|
||||||
@@ -41,22 +56,6 @@ function getStateFromStores() {
|
|||||||
loading: loading
|
loading: loading
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ChannelInviteModal extends React.Component {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.componentDidMount = this.componentDidMount.bind(this);
|
|
||||||
this.componentWillUnmount = this.componentWillUnmount.bind(this);
|
|
||||||
this.shouldComponentUpdate = this.shouldComponentUpdate.bind(this);
|
|
||||||
this.onShow = this.onShow.bind(this);
|
|
||||||
this.onHide = this.onHide.bind(this);
|
|
||||||
this.onListenerChange = this.onListenerChange.bind(this);
|
|
||||||
this.handleInvite = this.handleInvite.bind(this);
|
|
||||||
|
|
||||||
this.isShown = false;
|
|
||||||
this.state = getStateFromStores();
|
|
||||||
}
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
$(React.findDOMNode(this)).on('hidden.bs.modal', this.onHide);
|
$(React.findDOMNode(this)).on('hidden.bs.modal', this.onHide);
|
||||||
$(React.findDOMNode(this)).on('show.bs.modal', this.onShow);
|
$(React.findDOMNode(this)).on('show.bs.modal', this.onShow);
|
||||||
@@ -70,9 +69,6 @@ export default class ChannelInviteModal extends React.Component {
|
|||||||
ChannelStore.removeChangeListener(this.onListenerChange);
|
ChannelStore.removeChangeListener(this.onListenerChange);
|
||||||
UserStore.removeChangeListener(this.onListenerChange);
|
UserStore.removeChangeListener(this.onListenerChange);
|
||||||
}
|
}
|
||||||
shouldComponentUpdate() {
|
|
||||||
return this.isShown;
|
|
||||||
}
|
|
||||||
onShow() {
|
onShow() {
|
||||||
this.isShown = true;
|
this.isShown = true;
|
||||||
this.onListenerChange();
|
this.onListenerChange();
|
||||||
@@ -81,8 +77,8 @@ export default class ChannelInviteModal extends React.Component {
|
|||||||
this.isShown = false;
|
this.isShown = false;
|
||||||
}
|
}
|
||||||
onListenerChange() {
|
onListenerChange() {
|
||||||
var newState = getStateFromStores();
|
var newState = this.getStateFromStores();
|
||||||
if (!utils.areStatesEqual(this.state, newState)) {
|
if (!utils.areStatesEqual(this.state, newState) && this.isShown) {
|
||||||
this.setState(newState);
|
this.setState(newState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user