OSDN Git Service

fix: debounce balance refresh
authorj <coffce404@gmail.com>
Fri, 30 Jul 2021 09:32:43 +0000 (17:32 +0800)
committerj <coffce404@gmail.com>
Fri, 30 Jul 2021 09:32:43 +0000 (17:32 +0800)
src/models/account.js
src/views/assetList.vue
src/views/backup/backupMnemonic.vue
src/views/home.vue

index 0ac2ae9..0e488b4 100644 (file)
@@ -10,12 +10,11 @@ import { wallet, setChain, setNet } from './wallet'
 let account = {
   // setupNet: bytom.setupNet
   setupNet: (net) => {
+    // older version compat
     const network = net.substr(0, 7)
     const chain = net.substr(7)
-    console.log(network, chain);
     setChain(chain)
     setNet(network)
-    // older version
     bytom.setupNet(net)
   }
 }
@@ -239,11 +238,16 @@ account.balance = function(address , context) {
     // bytom.accounts
       // .listAddressUseServer(address)
       .then(address => {
+        const _bytom = context.bytom.clone();
+        const isVapor = _bytom.settings.netType === 'vapor'
+
+        if (address.address !== context.bytom.currentAccount[isVapor ? 'vpAddress' : 'address']) {
+          return
+        }
+
         let balances = address.balances || []
         let votes = address.votes || []
-        const _bytom = context.bytom.clone();
 
-        const isVapor = _bytom.settings.netType === 'vapor'
         const _currentBalance = isVapor? _bytom.currentAccount.vpBalances : _bytom.currentAccount.balances
 
           Sentry.configureScope(function(scope) {
index 0aee7be..8422e3d 100644 (file)
@@ -132,7 +132,7 @@ font-size: 15px;
                         <div class="text-align-right">
                           <div class="value">{{transaction.direct}}{{transaction.val}} {{currentAsset.asset.symbol}}</div>
 
-                          <div class="addr color-red" v-if="!transaction.status">
+                          <div class="addr color-red" v-if="!transaction.blockHeight">
                             {{ $t('listAsset.fail') }}
                           </div>
                           <div class="addr color-grey" v-else-if="transaction.hasOwnProperty('blockTimestamp')">
index b4d2c92..7d0454d 100644 (file)
@@ -9,6 +9,7 @@
     text-align: center;
     color: rgba(0, 0, 0, 0.88);
     margin: 10px 0;
+    white-space: pre;
   }
 
   .mnemnonic-box{
@@ -44,7 +45,7 @@
         </section>
         <section >
           <div class="mnemnonic-box">
-                <span class="mnemonic" v-for="n in inputMnemonic">{{ n }} </span>
+                <span class="mnemonic" v-for="n in inputMnemonic">{{ n }}  </span>
             </div>
             <p class="hint">{{ $t('backup.mnemonicHint') }}</p>
             <button class="btn btn-primary" @click="back">{{ $t("backup.ok") }}</button>
index 27af89d..c085924 100644 (file)
@@ -444,14 +444,13 @@ export default {
               return;
             }
 
-            let addr
-            if(this.netType === 'vapor'){
-              addr = newVal.vpAddress
-            }else{
-              addr = newVal.address
-            }
-            console.log('currentAccount change', this.netType)
-            this.refreshBalance(addr)
+            // let addr
+            // if(this.netType === 'vapor'){
+            //   addr = newVal.vpAddress
+            // }else{
+            //   addr = newVal.address
+            // }
+            // this.refreshBalance(addr)
         },
     },
     computed: {
@@ -478,7 +477,7 @@ export default {
                 bytom.keychain.pairs[this.net][bytom.currentAccount.alias].vpAddress = accounts.address
 
                 this[Actions.UPDATE_STORED_BYTOM](bytom).then(() => {
-                  this.setupRefreshTimer()
+                  // this.setupRefreshTimer()
                 })
 
                 return accounts.address
@@ -559,7 +558,7 @@ export default {
               bytom.keychain.pairs[this.net][bytom.currentAccount.alias].vpAddress = accounts.address
 
               this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
-                this.setupRefreshTimer()
+                this.refreshBalance(this.address)
               })
             }).catch(error =>{
               let e = error
@@ -572,7 +571,8 @@ export default {
             })
           }else{
             this[Actions.UPDATE_STORED_BYTOM](bytom).then(()=>{
-              this.setupRefreshTimer()
+              this.refreshBalance(this.address)
+              // this.setupRefreshTimer()
             })
           }
         },