diff --git a/app/ajax/service.js b/app/ajax/service.js index 64f2dae8..a281c15e 100644 --- a/app/ajax/service.js +++ b/app/ajax/service.js @@ -1,6 +1,9 @@ import { inject as service } from '@ember/service'; import { readOnly } from '@ember/object/computed'; + import AjaxService from 'ember-ajax/services/ajax'; +import AJAXPromise from 'ember-ajax/-private/promise'; + import retryWithBackoff from 'ember-backoff/retry-with-backoff'; export default AjaxService.extend({ @@ -12,6 +15,30 @@ export default AjaxService.extend({ contentType: 'application/json', request(...args) { - return retryWithBackoff(() => this._super(...args)); + return retryWithBackoff(() => this._request(...args), 10, 500); + }, + + // https://github.com/ember-cli/ember-ajax/issues/296 + _request(url, options) { + const hash = this.options(url, options); + const internalPromise = this._makeRequest(hash); + + const ajaxPromise = new AJAXPromise((resolve, reject) => { + internalPromise + .then(({ response }) => { + resolve(response); + }) + .catch(({ response }) => { + if (response instanceof Error) { + return reject(response); + } + + reject(response.response); + }); + }, `ember-ajax: ${hash.type} ${hash.url} response`); + + ajaxPromise.xhr = internalPromise.xhr; + + return ajaxPromise; }, }); diff --git a/app/components/wallet-overview/template.hbs b/app/components/wallet-overview/template.hbs index cdfa6069..12bb8752 100644 --- a/app/components/wallet-overview/template.hbs +++ b/app/components/wallet-overview/template.hbs @@ -1,36 +1,40 @@
- Wallet Balance: ⬡ {{format-amount wallet.balance}} + Total Balance: ⬡ {{format-amount wallet.balance}}
-Account | -Balance | -Pending | -
---|---|---|
- {{#link-to 'wallets.accounts' wallet acc}} - {{truncate acc.id 30}} - {{/link-to}} - | -- {{format-amount acc.balance}} - | -- {{format-amount acc.pending}} - | -
+ Wallet: {{wallet.id}} +
-{{!-- {{truncate "Lorem ipsum dolor sit amet, consectetur adipiscing elit." 20}} --}} +{{#if wallet.accounts}} +Account | +Balance | +Pending | +
---|---|---|
+ {{#link-to 'wallets.accounts' wallet acc}} + {{truncate acc.id 30}} + {{/link-to}} + | ++ {{format-amount acc.balance}} + | ++ {{format-amount acc.pending}} + | +