mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
Flush store after unmounting coa component to force refresh on new user request
This commit is contained in:
parent
742c1bc6e0
commit
c3a1b9b626
@ -7,7 +7,8 @@ import CoaFetcher from '../fetchers/coa_fetcher';
|
|||||||
class CoaActions {
|
class CoaActions {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.generateActions(
|
this.generateActions(
|
||||||
'updateCoa'
|
'updateCoa',
|
||||||
|
'flushCoa'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,9 +27,7 @@ class CoaActions {
|
|||||||
this.actions.updateCoa(res.coa);
|
this.actions.updateCoa(res.coa);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log(err)
|
|
||||||
console.logGlobal(err);
|
console.logGlobal(err);
|
||||||
this.actions.updateCoa('Something went wrong, please try again later.');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ let CoaDetails = React.createClass({
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
CoaStore.listen(this.onChange);
|
CoaStore.listen(this.onChange);
|
||||||
if (this.props.edition.coa) {
|
if(this.props.edition.coa) {
|
||||||
CoaActions.fetchOne(this.props.edition.coa);
|
CoaActions.fetchOne(this.props.edition.coa);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -401,6 +401,9 @@ let CoaDetails = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
// Flushing the coa state is essential to not displaying the same
|
||||||
|
// data to the user while he's on another edition
|
||||||
|
CoaActions.flushCoa();
|
||||||
CoaStore.unlisten(this.onChange);
|
CoaStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -409,7 +412,7 @@ let CoaDetails = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.state.coa && this.state.coa.url_safe) {
|
if(this.state.coa && this.state.coa.url_safe) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<p className="text-center ascribe-button-list">
|
<p className="text-center ascribe-button-list">
|
||||||
@ -427,8 +430,7 @@ let CoaDetails = React.createClass({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
} else if(typeof this.state.coa === 'string'){
|
||||||
else if (typeof this.state.coa === 'string'){
|
|
||||||
return (
|
return (
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
{this.state.coa}
|
{this.state.coa}
|
||||||
|
@ -13,9 +13,9 @@ class CoaStore {
|
|||||||
onUpdateCoa(coa) {
|
onUpdateCoa(coa) {
|
||||||
this.coa = coa;
|
this.coa = coa;
|
||||||
}
|
}
|
||||||
onErrorCoa(err) {
|
|
||||||
|
onFlushCoa() {
|
||||||
this.coa = {};
|
this.coa = {};
|
||||||
//this.coa = err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user