1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00

Merged in AD-610-on-switching-edition-detail-coa-d (pull request #17)

Flush store after unmounting coa component to force refresh on new user request
This commit is contained in:
TimDaubenschuetz 2015-07-23 14:35:09 +02:00
commit 90b0047eb8
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

@ -391,7 +391,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 {
@ -400,6 +400,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);
},
@ -408,7 +411,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">
@ -426,8 +429,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
}
}