|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import Toggle from '@vueform/toggle' |
3 | | - import { computed, onMounted, ref } from 'vue' |
| 3 | + import { computed, ref, watch } from 'vue' |
4 | 4 | import { Connection, type ElectrumNetworkProvider, Config, type BalanceResponse } from "mainnet-js" |
5 | 5 | import { useStore } from '../stores/store' |
6 | 6 | import { useSettingsStore } from '../stores/settingsStore' |
|
47 | 47 |
|
48 | 48 | const platformString = isBrowser ? 'browser' : (isCapacitor ? 'app' : 'application'); |
49 | 49 |
|
50 | | - onMounted(async () => { |
51 | | - indexedDbCacheSizeMB.value = await calculateIndexedDBSizeMB(); |
52 | | - localStorageSizeMB.value = calculateLocalStorageSizeMB() |
53 | | - }); |
54 | | -
|
55 | 50 | if(isDesktop) getLatestGithubRelease() |
56 | 51 |
|
57 | 52 | async function getLatestGithubRelease(){ |
|
87 | 82 | return totalSize / (1024 ** 2); // Convert to MB |
88 | 83 | } |
89 | 84 |
|
| 85 | + async function loadCacheSizes() { |
| 86 | + indexedDbCacheSizeMB.value = await calculateIndexedDBSizeMB(); |
| 87 | + localStorageSizeMB.value = calculateLocalStorageSizeMB() |
| 88 | + }; |
| 89 | +
|
| 90 | + // Loading Cache data is expensive with capacitor so don't block UI on loading |
| 91 | + watch(displaySettingsMenu, (newVal) => { |
| 92 | + // Load cache sizes if the user opens the advanced settings menu |
| 93 | + if (newVal === 3) { |
| 94 | + // defer execution to allow UI to render first |
| 95 | + setTimeout(async () => await loadCacheSizes(), 0); |
| 96 | + } |
| 97 | + }); |
| 98 | +
|
90 | 99 | async function changeCurrency(){ |
91 | 100 | Config.DefaultCurrency = selectedCurrency.value; |
92 | 101 | settingsStore.currency = selectedCurrency.value; |
|
0 commit comments