From 7ba91a15b92a2c767ff4b394ce8e32ba66c37bd2 Mon Sep 17 00:00:00 2001
From: GusevPM <108540436+GusevPM@users.noreply.github.com>
Date: Fri, 22 Sep 2023 19:44:47 +0400
Subject: [PATCH] Fix ticket tab display (#561)
* Fix ticket tab display + code smells
* Fix code smell
* Fix contract data reset on address change
---
src/components/Bookmarks/BookmarkButton.vue | 4 --
src/components/Bookmarks/Bookmarks.vue | 4 --
src/views/contract/Contract.vue | 72 ++++++++++-----------
src/views/contract/TicketTab/TicketTab.vue | 1 -
4 files changed, 35 insertions(+), 46 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..243d5aec 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,21 @@ 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;
+ this.fetchContractData();
+ })
+ .catch((err) => {
+ this.showError(err);
+ })
},
getContract() {
if (
@@ -232,7 +232,6 @@ export default {
) {
return;
}
- this.contractLoading = true;
this.api
.getContract(this.network, this.address)
.then((res) => {
@@ -248,31 +247,30 @@ 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;
- }
+ this.onChainViews = [];
+ this.tokensTotal = 0;
+ this.metadata = null;
- 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 = [];