From 143eaeade66ec78caa99dac5d9d61f3710681b81 Mon Sep 17 00:00:00 2001 From: GussevPM Date: Fri, 22 Sep 2023 02:26:47 +0400 Subject: [PATCH] Fix ticket tab display + code smells --- src/components/Bookmarks/BookmarkButton.vue | 4 -- src/components/Bookmarks/Bookmarks.vue | 4 -- src/views/contract/Contract.vue | 73 ++++++++++----------- src/views/contract/TicketTab/TicketTab.vue | 1 - 4 files changed, 35 insertions(+), 47 deletions(-) diff --git a/src/components/Bookmarks/BookmarkButton.vue b/src/components/Bookmarks/BookmarkButton.vue index 2bf216ad..ed2c6867 100644 --- a/src/components/Bookmarks/BookmarkButton.vue +++ b/src/components/Bookmarks/BookmarkButton.vue @@ -109,7 +109,3 @@ export default { } } - - - \ No newline at end of file diff --git a/src/components/Bookmarks/Bookmarks.vue b/src/components/Bookmarks/Bookmarks.vue index d7cb67b2..aea4a5a5 100644 --- a/src/components/Bookmarks/Bookmarks.vue +++ b/src/components/Bookmarks/Bookmarks.vue @@ -62,7 +62,3 @@ export default { } } - - - \ No newline at end of file diff --git a/src/views/contract/Contract.vue b/src/views/contract/Contract.vue index ef5794bd..74f3a929 100644 --- a/src/views/contract/Contract.vue +++ b/src/views/contract/Contract.vue @@ -110,7 +110,6 @@ export default { }, data: () => ({ accountType: '', - contractLoading: true, contract: {}, contractInfo: {}, balance: 0, @@ -181,7 +180,6 @@ export default { showClipboardOK: "showClipboardOK", }), loadOnChainViews() { - this.onChainViews = []; if (!this.network || !this.address) { return } @@ -211,19 +209,24 @@ export default { handleSearchBoxBlur() { this.isComboBoxExpanded = false; }, - async init() { - await this.getInfo(); - this.tokensTotal = 0; - this.metadata = null; + init() { + this + .getInfo() + .then((res) => { + this.handleInfo(res); - this.alias = await this.getAlias(this.network, this.address); - if (this.isContract) { - this.getContract(); - this.loadOnChainViews(); - } else { - this.contract = this.contractInfo; - } - this.getMetadata(); + return this.getAlias(this.network, this.address); + }) + .then((alias) => { + this.alias = alias; + return; + }) + .then(() => { + this.fetchContractData(); + }) + .catch((err) => { + this.showError(err); + }) }, getContract() { if ( @@ -232,7 +235,6 @@ export default { ) { return; } - this.contractLoading = true; this.api .getContract(this.network, this.address) .then((res) => { @@ -248,31 +250,26 @@ export default { this.showError(err); } }) - .finally(() => (this.contractLoading = false)); + }, + fetchContractData() { + if (this.isContract) { + this.getContract(); + this.loadOnChainViews(); + } else { + this.contract = this.contractInfo; + } + this.getMetadata(); }, getInfo() { - this.contractLoading = true; - this.api - .getAccountInfo(this.network, this.address) - .then((res) => { - if (!res) return; - this.contractInfo = res; - this.accountType = res.account_type; - if (res.balance !== undefined) { - this.balance = res.balance || 0; - return; - } - - return this.rpc.getTezosBalance(this.network, 'head', this.address); - }) - .then((res) => { - if (!res) return; - this.balance = res.balance || 0; - }) - .catch((err) => { - this.showError(err); - }) - .finally(() => (this.contractLoading = false)); + return this.api.getAccountInfo(this.network, this.address) + }, + handleInfo(info) { + if (!info) return; + this.contractInfo = info; + this.accountType = info.account_type; + if (info.balance !== undefined) { + this.balance = info.balance || 0; + } }, getMetadata() { if (!this.metadataService.created()) return; diff --git a/src/views/contract/TicketTab/TicketTab.vue b/src/views/contract/TicketTab/TicketTab.vue index 49a981d4..a0355a7b 100644 --- a/src/views/contract/TicketTab/TicketTab.vue +++ b/src/views/contract/TicketTab/TicketTab.vue @@ -174,7 +174,6 @@ export default { this.getTickectUpdatesByOperation(this.network, this.operationId); } }, - // Не понял секцию ниже.. watch: { 'address': function(newAddress){ this.updates = [];