diff --git a/src/components/entercode/PackSimulator.js b/src/components/entercode/PackSimulator.js index bbe0afe..b1c58e8 100644 --- a/src/components/entercode/PackSimulator.js +++ b/src/components/entercode/PackSimulator.js @@ -25,18 +25,17 @@ export default class PackSimulator extends React.Component { } render() { - if (API.urls === null || - API.portal === null || - API.cards === null) { - return (Loading...); - } - if (this.loaded == false) { - API.buildCollection([{'cards': 'attacks'}, , {'cards': 'battlegear'}, {'cards': 'creatures'}, {'cards': 'locations'}, {'cards': 'mugic'}]) - .then(() => { - this.setupDB(); - this.loaded = true; - }); + if (API.urls !== null && + API.portal !== null && + API.cards !== null + ) { + API.buildCollection([{'cards': 'attacks'}, , {'cards': 'battlegear'}, {'cards': 'creatures'}, {'cards': 'locations'}, {'cards': 'mugic'}]) + .then(() => { + this.setupDB(); + this.loaded = true; + }); + } return (Loading...); } diff --git a/src/components/portal/Category/Attacks.js b/src/components/portal/Category/Attacks.js index d186a2b..60826e0 100644 --- a/src/components/portal/Category/Attacks.js +++ b/src/components/portal/Category/Attacks.js @@ -12,24 +12,22 @@ export default class Attacks extends React.Component { @observable loaded = false; render() { + if (this.loaded == false) { + if (API.urls !== null && + API.portal !== null && + API.cards !== null + ) { + API.buildCollection([{'cards': 'attacks'}, {'portal': 'attacks'}]) + .then(() => { + this.loaded = true; + }); + } + return (Loading...); + } let path = this.props.location.pathname.split("/"); if (path[path.length-1] == "") path.pop(); // Remove trailing backslash - if (API.urls === null || - API.portal === null || - API.cards === null) { - return (Loading...); - } - - if (this.loaded == false) { - API.buildCollection([{'cards': 'attacks'}, {'portal': 'attacks'}]) - .then(() => { - this.loaded = true; - }); - return (Loading...); - } - const output = API.portal.attacks.data.map((attack, i) => { const card_data = API.cards.attacks.findOne({'gsx$name': attack.gsx$name}); return ( diff --git a/src/components/portal/Category/Battlegear.js b/src/components/portal/Category/Battlegear.js index 5d2f9d1..6b1bc10 100644 --- a/src/components/portal/Category/Battlegear.js +++ b/src/components/portal/Category/Battlegear.js @@ -12,23 +12,22 @@ export default class Battlegear extends React.Component { @observable loaded = false; render() { + if (this.loaded == false) { + if (API.urls !== null && + API.portal !== null && + API.cards !== null + ) { + API.buildCollection([{'cards': 'battlegear'}, {'portal': 'battlegear'}]) + .then(() => { + this.loaded = true; + }); + } + return (Loading...); + } + let path = this.props.location.pathname.split("/"); if (path[path.length-1] == "") path.pop(); // Remove trailing backslash - if (API.urls === null || - API.portal === null || - API.cards === null) { - return (Loading...); - } - - if (this.loaded == false) { - API.buildCollection([{'cards': 'battlegear'}, {'portal': 'battlegear'}]) - .then(() => { - this.loaded = true; - }); - return (Loading...); - } - const battlegear = API.portal.battlegear.data; const output = battlegear.map((single_battlegear, i) => { diff --git a/src/components/portal/Category/Creatures.js b/src/components/portal/Category/Creatures.js index da758d9..450d7ea 100644 --- a/src/components/portal/Category/Creatures.js +++ b/src/components/portal/Category/Creatures.js @@ -16,23 +16,22 @@ export default class Creatures extends React.Component { // /portal/Creatures/{Tribe} // The first / gets counted render() { + if (this.loaded == false) { + if (API.urls !== null && + API.portal !== null && + API.cards !== null + ) { + API.buildCollection([{'cards': 'creatures'}, {'portal': 'creatures'}]) + .then(() => { + this.loaded = true; + }); + } + return (Loading...); + } + let path = this.props.location.pathname.split("/"); if (path[path.length-1] == "") path.pop(); // Remove trailing backslash - if (API.urls === null || - API.portal === null || - API.cards === null) { - return (Loading...); - } - - if (this.loaded == false) { - API.buildCollection([{'cards': 'creatures'}, {'portal': 'creatures'}]) - .then(() => { - this.loaded = true; - }); - return (Loading...); - } - const tribe = (() => { if (path.length >= 4 && API.tribes.includes(path[3])) return path[3]; else return null; diff --git a/src/components/portal/Category/Locations.js b/src/components/portal/Category/Locations.js index ac0a620..0f86fbb 100644 --- a/src/components/portal/Category/Locations.js +++ b/src/components/portal/Category/Locations.js @@ -12,24 +12,22 @@ export default class Locations extends React.Component { @observable loaded = false; render() { + if (this.loaded == false) { + if (API.urls !== null && + API.portal !== null && + API.cards !== null + ) { + API.buildCollection([{'cards': 'locations'}, {'portal': 'locations'}]) + .then(() => { + this.loaded = true; + }); + } + return (Loading...); + } let path = this.props.location.pathname.split("/"); if (path[path.length-1] == "") path.pop(); // Remove trailing backslash - if (API.urls === null || - API.portal === null || - API.cards === null) { - return (Loading...); - } - - if (this.loaded == false) { - API.buildCollection([{'cards': 'locations'}, {'portal': 'locations'}]) - .then(() => { - this.loaded = true; - }); - return (Loading...); - } - const locations = API.portal.locations.data; const output = locations.map((location, i) => { diff --git a/src/components/portal/Category/Mugic.js b/src/components/portal/Category/Mugic.js index bbfaeca..16f0aaf 100644 --- a/src/components/portal/Category/Mugic.js +++ b/src/components/portal/Category/Mugic.js @@ -16,25 +16,22 @@ export default class Mugic extends React.Component { // /portal/{Tribe}/Mugic/ // The first / gets counted render() { - const store = API; + if (this.loaded == false) { + if (API.urls !== null && + API.portal !== null && + API.cards !== null + ) { + API.buildCollection([{'cards': 'mugic'}, {'portal': 'mugic'}]) + .then(() => { + this.loaded = true; + }); + } + return (Loading...); + } let path = this.props.location.pathname.split("/"); if (path[path.length-1] == "") path.pop(); // Remove trailing backslash - if (API.urls === null || - API.portal === null || - API.cards === null) { - return (Loading...); - } - - if (this.loaded == false) { - API.buildCollection([{'cards': 'mugic'}, {'portal': 'mugic'}]) - .then(() => { - this.loaded = true; - }); - return (Loading...); - } - const tribe = (() => { if (path.length >= 4 && API.tribes.includes(path[3])) return path[3]; else return null; diff --git a/src/components/portal/Category/Tribes.js b/src/components/portal/Category/Tribes.js index f486e7e..b4049f5 100644 --- a/src/components/portal/Category/Tribes.js +++ b/src/components/portal/Category/Tribes.js @@ -23,47 +23,24 @@ export default class Tribes extends React.Component { // to display the respective subcategories // -> /{Tribe}/Mugic || /{Tribe}/Creatures render() { + if (this.loaded == false) { + if (API.urls !== null && + API.portal !== null && + API.cards !== null + ) { + API.buildCollection([{'cards': 'creatures'}, {'portal': 'creatures'}, {'cards': 'mugic'}, {'portal': 'mugic'}]) + .then(() => { + this.loaded = true; + }); + } + return (Loading...); + } let path = this.props.location.pathname.split("/"); if (path[path.length-1] == "") path.pop(); // Remove trailing backslash let tribe = path[2]; - if (API.urls === null || - API.portal === null || - API.cards === null) { - return (Loading...); - } - - if (!API.tribes.includes(tribe)) { - return( -