diff --git a/src/views/big_map/BigMap.vue b/src/views/big_map/BigMap.vue index 960a44d4..a8b07ffa 100644 --- a/src/views/big_map/BigMap.vue +++ b/src/views/big_map/BigMap.vue @@ -101,32 +101,34 @@ export default { }), created() { this.getBigMap(); - this.getBigMapActions(); - this.getTotalBytes(); }, methods: { ...mapActions(["showError"]), shortcutOnly, getBigMap() { - this.api + if (this.loading) return; + this.loading = true; + + return this.api .getContractBigMap(this.network, this.ptr) - .then(res => { - if (!res) return; - this.bigmap = res; + .then(bigMap => { + if (!bigMap) return; + this.bigmap = bigMap; + return this.api + .getContractBigMapActions(this.network, this.ptr) + }) + .then((actions) => { + if (!actions) return; + if (!actions.items) return; + this.actions = actions.items; + + if (this.bigmap.total_keys) + return this.rpc + .getBigMapTotalBytes(this.network, "head", this.ptr) }) - .catch(err => { - console.log(err); - this.showError(err); - }); - }, - getBigMapActions() { - this.loading = true; - this.api - .getContractBigMapActions(this.network, this.ptr) .then((res) => { if (!res) return; - if (!res.items) return; - this.actions = res.items; + this.totalBytes = parseInt(res.data, 10); }) .catch((err) => { console.log(err); @@ -138,18 +140,6 @@ export default { this.loading = false; }); }, - getTotalBytes() { - this.rpc - .getBigMapTotalBytes(this.network, "head", this.ptr) - .then((res) => { - if (!res) return; - this.totalBytes = parseInt(res.data, 10); - }) - .catch((err) => { - console.log(err); - this.showError(err); - }); - }, }, watch: { ptr: 'getBigMap'