ApproveLoader.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <div v-if="isReconnectButtonShow" class="loading-alert">
  3. {{ $t('mobileWallet.loading.alert') }}
  4. <b-button type="is-primary" size="small" class="max-content is-outlined" @click="onReconnect">
  5. {{ $t('mobileWallet.loading.action') }}
  6. </b-button>
  7. </div>
  8. </template>
  9. <script>
  10. import { mapState, mapGetters, mapActions } from 'vuex'
  11. import { SECOND } from '@/constants'
  12. export default {
  13. data() {
  14. return {
  15. isReconnectButtonShow: false
  16. }
  17. },
  18. computed: {
  19. ...mapGetters('metamask', ['isWalletConnect', 'netId']),
  20. ...mapState('loading', ['enabled'])
  21. },
  22. mounted() {
  23. this.onClearData()
  24. if (this.isWalletConnect) {
  25. this.timeout = setTimeout(() => {
  26. this.isReconnectButtonShow = true
  27. }, SECOND * 20)
  28. }
  29. },
  30. destroyed() {
  31. this.onClearData()
  32. },
  33. methods: {
  34. ...mapActions('metamask', ['mobileWalletReconnect']),
  35. async onReconnect() {
  36. await this.mobileWalletReconnect(this.netId)
  37. },
  38. onClearData() {
  39. if (this.timeout) {
  40. this.isReconnectButtonShow = false
  41. clearTimeout(this.timeout)
  42. }
  43. }
  44. }
  45. }
  46. </script>