Skip to content

Commit cf76178

Browse files
committed
improve loading of cache sizes for capacitor
1 parent c735029 commit cf76178

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/components/settingsMenu.vue

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import Toggle from '@vueform/toggle'
3-
import { computed, onMounted, ref } from 'vue'
3+
import { computed, ref, watch } from 'vue'
44
import { Connection, type ElectrumNetworkProvider, Config, type BalanceResponse } from "mainnet-js"
55
import { useStore } from '../stores/store'
66
import { useSettingsStore } from '../stores/settingsStore'
@@ -47,11 +47,6 @@
4747
4848
const platformString = isBrowser ? 'browser' : (isCapacitor ? 'app' : 'application');
4949
50-
onMounted(async () => {
51-
indexedDbCacheSizeMB.value = await calculateIndexedDBSizeMB();
52-
localStorageSizeMB.value = calculateLocalStorageSizeMB()
53-
});
54-
5550
if(isDesktop) getLatestGithubRelease()
5651
5752
async function getLatestGithubRelease(){
@@ -87,6 +82,20 @@
8782
return totalSize / (1024 ** 2); // Convert to MB
8883
}
8984
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+
9099
async function changeCurrency(){
91100
Config.DefaultCurrency = selectedCurrency.value;
92101
settingsStore.currency = selectedCurrency.value;

0 commit comments

Comments
 (0)