Commit d51b3e9f authored by Juorder Antonio's avatar Juorder Antonio

create a domain, that check if the returned length og DL is equal to the...

create a domain, that check if the returned length og DL is equal to the operation running, if it is just return state if not call itself again
parent c1cdb9c4
module.exports = {"main":{"js":"/430297bundle.js"}}
\ No newline at end of file
module.exports = {"main":{"js":"/012994bundle.js"}}
\ No newline at end of file
......@@ -35,7 +35,7 @@ export default class AddDistributionListModal extends React.Component {
if (this.isStoreEnabled) {
DomainStore.addDistributionList(data);
} else {
DomainStore.emitDistributionListsChange();
DomainStore.emitDistributionListsChange('add');
}
GlobalActions.emitEndLoading();
this.props.onHide();
......
......@@ -39,19 +39,45 @@ export default class DomainDistributionList extends React.Component {
return lists;
}
getLists() {
getLists(label) {
const tag = label || null;
const domain = this.props.domain;
let condition;
setTimeout(() => {
domain.getAllDistributionLists(
(err, lists) => {
if (this.isStoreEnabled) {
DomainStore.setDistibutionLists(domain, lists);
}
if (tag === 'add') {
condition = this.state.length + 1;
}
if (tag === 'remove') {
condition = this.state.length - 1;
}
this.listscache = lists;
this.setState({lists});
const length = lists.length;
if (!tag) {
return this.setState({
lists,
length
});
}
if (condition === lists.length) {
return this.setState({
lists,
length
});
} else {
this.getLists(tag);
}
}
);
}, 1000);
}, 100);
}
componentWillReceiveProps(nextProps) {
const page = parseInt(nextProps.location.query.page, 10) || 1;
......@@ -60,10 +86,10 @@ export default class DomainDistributionList extends React.Component {
offset: ((page - 1) * defaultLimit)
});
}
onListsChange() {
onListsChange(label) {
const lists = this.isStoreEnabled ? DomainStore.getDistributionLists(this.props.domain) : null;
if (!lists) {
return this.getLists();
return this.getLists(label);
}
return this.setState({lists});
......@@ -93,7 +119,7 @@ export default class DomainDistributionList extends React.Component {
if (this.isStoreEnabled) {
DomainStore.removeDistributionList(list.id);
} else {
DomainStore.emitDistributionListsChange();
DomainStore.emitDistributionListsChange('remove');
}
return sweetAlert(response);
......
......@@ -116,7 +116,7 @@ export default class BlockGeneralInfoMailbox extends React.Component {
<Button
btnAttrs={{
onClick: (e) => {
this.handleWatchDomain(e, `domains/${this.state.domainData.id}`, this.props.location);
this.handleWatchDomain(e, `/domains/${this.state.domainData.id}`, this.props.location);
}
}}
>
......
......@@ -317,8 +317,8 @@ class DomainStoreClass extends EventEmitter {
this.removeListener(eventTypes.ZONE_DNS_CHANGE_EVENT, zone);
}
emitDistributionListsChange() {
this.emit(eventTypes.DOMAIN_DLS_CHANGE_EVENT);
emitDistributionListsChange(params) {
this.emit(eventTypes.DOMAIN_DLS_CHANGE_EVENT, params);
}
addDistributionListsChangeListener(callback) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment