From b2fe4f523e39d23ec7b8106b5bd8854252670d09 Mon Sep 17 00:00:00 2001 From: FaboWeb Date: Thu, 9 Jan 2020 10:21:13 -0400 Subject: [PATCH 01/14] set fetch policies correctly --- src/ActionModal/components/ActionModal.vue | 39 +------------------ .../components/DelegationModal.vue | 2 + src/ActionModal/components/SendModal.vue | 25 ++++++++++++ .../components/UndelegationModal.vue | 23 +++++++++++ src/components/common/TmBalance.vue | 21 +--------- src/components/governance/PageProposal.vue | 22 +++-------- src/components/governance/PageProposals.vue | 4 +- .../staking/DelegationsOverview.vue | 4 +- src/components/staking/PageValidator.vue | 22 ++--------- src/components/staking/PageValidators.vue | 1 + src/components/staking/TableValidators.vue | 3 +- src/components/staking/Undelegations.vue | 4 +- src/components/wallet/PageTransactions.vue | 1 + src/vuex/modules/session.js | 15 +------ 14 files changed, 71 insertions(+), 115 deletions(-) diff --git a/src/ActionModal/components/ActionModal.vue b/src/ActionModal/components/ActionModal.vue index de89b0ee53..4fc5fea6ac 100644 --- a/src/ActionModal/components/ActionModal.vue +++ b/src/ActionModal/components/ActionModal.vue @@ -506,7 +506,6 @@ export default { userAddress: this.session.address, rewards: this.rewards, // state.distribution.rewards, totalRewards: this.overview.totalRewards, // getters.totalRewards, - delegations: this.delegations, // state.delegates.delegates, bondDenom: this.network.stakingDenom, // getters.bondDenom, isExtensionAccount: this.isExtensionAccount, account: this.overview.accountInformation @@ -722,7 +721,6 @@ export default { overview(networkId: $networkId, address: $address) { totalRewards liquidStake - totalStake accountInformation { accountNumber sequence @@ -730,6 +728,7 @@ export default { } } `, + fetchPolicy: "cache-and-network", variables() { /* istanbul ignore next */ return { @@ -754,11 +753,8 @@ export default { query NetworkActionModal($networkId: String!) { network(id: $networkId) { id - testnet stakingDenom chain_id - rpc_url - api_url action_send action_claim_rewards action_delegate @@ -782,39 +778,6 @@ export default { return data.network } }, - delegations: { - query: gql` - query DelegationsActionModal( - $networkId: String! - $delegatorAddress: String! - ) { - delegations( - networkId: $networkId - delegatorAddress: $delegatorAddress - ) { - amount - validator { - operatorAddress - } - } - } - `, - skip() { - /* istanbul ignore next */ - return !this.session.address - }, - variables() { - /* istanbul ignore next */ - return { - networkId: this.networkId, - delegatorAddress: this.session.address - } - }, - update(data) { - /* istanbul ignore next */ - return data.delegations - } - }, $subscribe: { userTransactionAdded: { variables() { diff --git a/src/ActionModal/components/DelegationModal.vue b/src/ActionModal/components/DelegationModal.vue index 68181799e6..f90a7fee6c 100644 --- a/src/ActionModal/components/DelegationModal.vue +++ b/src/ActionModal/components/DelegationModal.vue @@ -347,6 +347,7 @@ export default { } } `, + fetchPolicy: "cache-and-network", skip() { /* istanbul ignore next */ return !this.address @@ -427,6 +428,7 @@ export default { result({ data }) { /* istanbul ignore next */ if (data.userTransactionAdded.success) { + this.$apollo.queries.balance.refetch() this.$apollo.queries.delegations.refetch() } } diff --git a/src/ActionModal/components/SendModal.vue b/src/ActionModal/components/SendModal.vue index 8019ca101a..26298cf653 100644 --- a/src/ActionModal/components/SendModal.vue +++ b/src/ActionModal/components/SendModal.vue @@ -134,6 +134,7 @@ import ActionModal from "./ActionModal" import transaction from "../utils/transactionTypes" import { toMicroDenom } from "src/scripts/common" import config from "src/../config" +import { UserTransactionAdded } from "src/gql" const defaultMemo = "(Sent via Lunie)" @@ -189,6 +190,9 @@ export default { } } }, + mounted() { + this.$apollo.queries.balance.refetch() + }, methods: { open() { this.$refs.actionModal.open() @@ -270,6 +274,7 @@ export default { } } `, + fetchPolicy: "cache-and-network", skip() { return !this.userAddress }, @@ -280,6 +285,26 @@ export default { denom: this.denom } } + }, + $subscribe: { + userTransactionAdded: { + variables() { + /* istanbul ignore next */ + return { + networkId: this.network, + address: this.userAddress + } + }, + skip() { + /* istanbul ignore next */ + return !this.userAddress + }, + query: UserTransactionAdded, + result() { + /* istanbul ignore next */ + this.$apollo.queries.balance.refetch() + } + } } } } diff --git a/src/ActionModal/components/UndelegationModal.vue b/src/ActionModal/components/UndelegationModal.vue index 7812ece1c6..d2803521f8 100644 --- a/src/ActionModal/components/UndelegationModal.vue +++ b/src/ActionModal/components/UndelegationModal.vue @@ -124,6 +124,7 @@ import TmFormMsg from "src/components/common/TmFormMsg" import transaction from "../utils/transactionTypes" import { toMicroDenom } from "src/scripts/common" import { formatBech32, validatorEntry } from "src/filters" +import { UserTransactionAdded } from "src/gql" export default { name: `undelegation-modal`, @@ -306,6 +307,7 @@ export default { } } `, + fetchPolicy: "cache-and-network", skip() { /* istanbul ignore next */ return !this.address @@ -363,6 +365,27 @@ export default { /* istanbul ignore next */ return data.validators } + }, + + $subscribe: { + userTransactionAdded: { + variables() { + /* istanbul ignore next */ + return { + networkId: this.network, + address: this.userAddress + } + }, + skip() { + /* istanbul ignore next */ + return !this.userAddress + }, + query: UserTransactionAdded, + result() { + /* istanbul ignore next */ + this.$apollo.queries.delegations.refetch() + } + } } } } diff --git a/src/components/common/TmBalance.vue b/src/components/common/TmBalance.vue index 9e67ea944e..970c99973b 100644 --- a/src/components/common/TmBalance.vue +++ b/src/components/common/TmBalance.vue @@ -53,12 +53,10 @@