Browse Source

add page loader

trade-portal-menu-icon
Phillip Lang Martinez 2 years ago
parent
commit
aad05a69c3
  1. 57
      qortal-ui-plugins/plugins/core/become-minter/become-minter.src.js

57
qortal-ui-plugins/plugins/core/become-minter/become-minter.src.js

@ -79,38 +79,47 @@ class BecomeMinter extends LitElement {
super.disconnectedCallback(); super.disconnectedCallback();
} }
getNodeInfo() { async getNodeInfo() {
parentEpml const nodeInfo = await parentEpml.request('apiCall', {
.request('apiCall', { url: `/admin/status` }) url: `/admin/status`,
.then((res) => { });
this.nodeInfo = res;
this.isPageLoading = false; return nodeInfo;
})
.catch(() => {
this.isPageLoading = false;
});
} }
async firstUpdated() { async firstUpdated() {
console.log({ change: 11 });
this.changeLanguage(); this.changeLanguage();
this.getNodeInfo();
this.addressInfo = this.addressInfo =
window.parent.reduxStore.getState().app.accountInfo.addressInfo; window.parent.reduxStore.getState().app.accountInfo.addressInfo;
this.isPageLoading = true;
await this.getRewardShareRelationship( try {
window.parent.reduxStore.getState().app?.selectedAddress?.address const [nodeInfo, myRewardShareArray] = await Promise.all([
); this.getNodeInfo(),
await this.getRewardShareRelationship(
window.parent.reduxStore.getState().app?.selectedAddress
?.address
),
]);
this.nodeInfo = nodeInfo;
this.rewardSharePublicKey =
myRewardShareArray[0]?.rewardSharePublicKey;
this.isPageLoading = false;
} catch (error) {
console.error(error);
this.isPageLoading = false;
}
} }
async getRewardShareRelationship(recipientAddress) { async getRewardShareRelationship(recipientAddress) {
let myRewardShareArray = await parentEpml.request('apiCall', { const myRewardShareArray = await parentEpml.request('apiCall', {
type: 'api', type: 'api',
url: `/addresses/rewardshares?minters=${recipientAddress}&recipients=${recipientAddress}`, url: `/addresses/rewardshares?minters=${recipientAddress}&recipients=${recipientAddress}`,
}); });
this.rewardSharePublicKey = myRewardShareArray[0]?.rewardSharePublicKey; return myRewardShareArray;
} }
_levelUpBlocks() { _levelUpBlocks() {
@ -129,6 +138,15 @@ class BecomeMinter extends LitElement {
this.rewardSharePublicKey; this.rewardSharePublicKey;
return html` return html`
${this.isPageLoading
? html`
<div class="loadingContainer">
<div class="loading"></div>
</div>
<div class="backdrop"></div>
`
: ''}
<div class="page-container"> <div class="page-container">
<h1 class="header-title"> <h1 class="header-title">
${translate('becomeMinterPage.bchange1')} ${translate('becomeMinterPage.bchange1')}
@ -137,7 +155,6 @@ class BecomeMinter extends LitElement {
<hr class="divider" /> <hr class="divider" />
</div> </div>
${this.isPageLoading ? html` <p>Loading....</p> ` : ''}
${isAlreadySponsored ${isAlreadySponsored
? '' ? ''
: html` <not-sponsored></not-sponsored> `} : html` <not-sponsored></not-sponsored> `}

Loading…
Cancel
Save