1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 05:31:58 +02:00

Flush store after unmounting coa component to force refresh on new user request

This commit is contained in:
Tim Daubenschütz 2015-07-22 15:16:56 +02:00
parent 742c1bc6e0
commit c3a1b9b626
3 changed files with 10 additions and 9 deletions

View File

@ -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.');
});
}
}

View File

@ -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}

View File

@ -13,9 +13,9 @@ class CoaStore {
onUpdateCoa(coa) {
this.coa = coa;
}
onErrorCoa(err) {
onFlushCoa() {
this.coa = {};
//this.coa = err
}
}