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

Improve robustness for server-side failing requests for COA

This commit is contained in:
Tim Daubenschütz 2015-12-08 17:38:04 +01:00
parent 2cc02d9599
commit e8d5e0390d
2 changed files with 21 additions and 13 deletions

View File

@ -64,8 +64,7 @@ let EditionContainer = React.createClass({
componentDidUpdate() { componentDidUpdate() {
const { editionMeta } = this.state; const { editionMeta } = this.state;
if(editionMeta.err && editionMeta.err.json && editionMeta.err.json.status === 404) {
if(editionMeta.err && editionMeta.err.status === 404) {
this.throws(new ResourceNotFoundError(getLangText("Oops, the edition you're looking for doesn't exist."))); this.throws(new ResourceNotFoundError(getLangText("Oops, the edition you're looking for doesn't exist.")));
} }
}, },

View File

@ -29,21 +29,30 @@ class EditionStore {
} }
} }
onSuccessFetchEdition({ edition }) { onSuccessFetchEdition(res) {
this.editionMeta.err = null; if(res && res.edition) {
this.editionMeta.idToFetch = null; this.edition = res.edition;
this.edition = edition; this.editionMeta.err = null;
this.editionMeta.idToFetch = null;
if(this.edition && this.edition.coa && typeof this.edition.coa.constructor !== Object) { if (this.edition.coa && this.edition.acl.acl_coa &&
this.getInstance().lookupCoa(); typeof this.edition.coa.constructor !== Object) {
} else if(this.edition && !this.edition.coa && this.edition.acl.acl_coa) { this.getInstance().lookupCoa();
this.getInstance().performCreateCoa(); } else if(!this.edition.coa && this.edition.acl.acl_coa) {
this.getInstance().performCreateCoa();
}
} else {
this.editionMeta.err = new Error('Problem fetching the edition');
} }
} }
onSuccessFetchCoa({ coa }) { onSuccessFetchCoa(res) {
this.coaMeta.err = null; if (res && res.coa && this.edition) {
this.edition.coa = coa; this.edition.coa = res.coa;
this.coaMeta.err = null;
} else {
this.coaMeta.err = new Error('Problem generating/fetching the COA');
}
} }
onFlushEdition() { onFlushEdition() {