diff --git a/package-lock.json b/package-lock.json index f80a159..2e6fc37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wallet", - "version": "1.23.0", + "version": "1.23.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "wallet", - "version": "1.23.0", + "version": "1.23.1", "license": "GPL", "dependencies": { "@chenfengyuan/vue-qrcode": "^2.0.0", diff --git a/package.json b/package.json index 83c51bd..8ea3ee2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wallet", - "version": "1.23.0", + "version": "1.23.1", "description": "Web wallet for managing $EDGE", "private": true, "license": "GPL", diff --git a/src/components/TransactionsTable.vue b/src/components/TransactionsTable.vue index 2afbb72..c1a47eb 100644 --- a/src/components/TransactionsTable.vue +++ b/src/components/TransactionsTable.vue @@ -61,13 +61,14 @@ import TransactionsTableItem from '@/components/TransactionsTableItem.vue' import { mapState } from 'vuex' const txsRefreshInterval = 5 * 1000 +const txCache = {} export default { name: 'TransactionsTable', data: function () { return { loaded: false, - loading: false, + loading: true, metadata: null, transactions: [], iTransactions: null @@ -90,6 +91,12 @@ export default { } }, mounted() { + const cached = txCache[this.address] + if (cached) { + this.transactions = cached.transactions + this.loaded = true + this.loading = false + } this.updateTransactions() // initiate polling this.iTransactions = setInterval(() => { @@ -102,21 +109,27 @@ export default { methods: { async updateTransactions() { this.loading = true + const addr = this.address + if (!addr) return // the sort query sent to index needs to include "-created", but this is hidden from user in browser url const sortQuery = this.$route.query.sort ? `${this.$route.query.sort},-timestamp` : '-timestamp' const transactions = await index.tx.transactions( import.meta.env.VITE_INDEX_API_URL, - this.address, + addr, { limit: this.limit, page: this.page, sort: sortQuery } ) - this.transactions = transactions.results - if (this.receiveMetadata) this.receiveMetadata(transactions.metadata) - this.loaded = true - this.loading = false + txCache[addr] = { transactions: transactions.results } + // Only update display if address hasn't changed during fetch + if (this.address === addr) { + this.transactions = transactions.results + if (this.receiveMetadata) this.receiveMetadata(transactions.metadata) + this.loaded = true + this.loading = false + } }, updateSorting(newSortQuery) { const query = { ...this.$route.query, sort: newSortQuery } @@ -125,6 +138,16 @@ export default { } }, watch: { + address(newAddr) { + const cached = txCache[newAddr] + if (cached) { + this.transactions = cached.transactions + } else { + this.transactions = [] + this.loaded = false + } + this.updateTransactions() + }, page() { this.updateTransactions() }, diff --git a/src/components/index/RestoreModal.vue b/src/components/index/RestoreModal.vue index 02af07f..cc7342d 100644 --- a/src/components/index/RestoreModal.vue +++ b/src/components/index/RestoreModal.vue @@ -7,6 +7,12 @@