mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +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 {
|
||||
constructor() {
|
||||
this.generateActions(
|
||||
'updateCoa'
|
||||
'updateCoa',
|
||||
'flushCoa'
|
||||
);
|
||||
}
|
||||
|
||||
@ -26,9 +27,7 @@ class CoaActions {
|
||||
this.actions.updateCoa(res.coa);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
console.logGlobal(err);
|
||||
this.actions.updateCoa('Something went wrong, please try again later.');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ let CoaDetails = React.createClass({
|
||||
|
||||
componentDidMount() {
|
||||
CoaStore.listen(this.onChange);
|
||||
if (this.props.edition.coa) {
|
||||
if(this.props.edition.coa) {
|
||||
CoaActions.fetchOne(this.props.edition.coa);
|
||||
}
|
||||
else {
|
||||
@ -401,6 +401,9 @@ let CoaDetails = React.createClass({
|
||||
},
|
||||
|
||||
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);
|
||||
},
|
||||
|
||||
@ -409,7 +412,7 @@ let CoaDetails = React.createClass({
|
||||
},
|
||||
|
||||
render() {
|
||||
if (this.state.coa && this.state.coa.url_safe) {
|
||||
if(this.state.coa && this.state.coa.url_safe) {
|
||||
return (
|
||||
<div>
|
||||
<p className="text-center ascribe-button-list">
|
||||
@ -427,8 +430,7 @@ let CoaDetails = React.createClass({
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
else if (typeof this.state.coa === 'string'){
|
||||
} else if(typeof this.state.coa === 'string'){
|
||||
return (
|
||||
<div className="text-center">
|
||||
{this.state.coa}
|
||||
|
@ -13,9 +13,9 @@ class CoaStore {
|
||||
onUpdateCoa(coa) {
|
||||
this.coa = coa;
|
||||
}
|
||||
onErrorCoa(err) {
|
||||
|
||||
onFlushCoa() {
|
||||
this.coa = {};
|
||||
//this.coa = err
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user