From fdb9031ce9860e628747d964dba908ca373f79a7 Mon Sep 17 00:00:00 2001 From: Simon Mcloughlin Date: Mon, 9 Dec 2024 14:55:50 +0000 Subject: [PATCH] code clean up --- Kukai Mobile/Modules/Home/HomeTabBarController.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Kukai Mobile/Modules/Home/HomeTabBarController.swift b/Kukai Mobile/Modules/Home/HomeTabBarController.swift index 6e0d41a7..15e937eb 100644 --- a/Kukai Mobile/Modules/Home/HomeTabBarController.swift +++ b/Kukai Mobile/Modules/Home/HomeTabBarController.swift @@ -458,10 +458,15 @@ public class HomeTabBarController: UITabBarController, UITabBarControllerDelegat records.append(BalanceService.FetchRequestRecord(address: address, type: refreshType)) } + + // If no address is passed in, thats short hand for refreshing the current address. However refreshing the current address will simply trigger an expensive cacheLoad if the data is not stale + // Until we move to middleware, simply add another check here. If its not stale, just skip and avoid the reload if records.count == 0 { let currentAddress = DependencyManager.shared.selectedWalletAddress ?? "" if DependencyManager.shared.balanceService.account.walletAddress == currentAddress, !DependencyManager.shared.balanceService.isCacheStale(forAddress: currentAddress) { // Do nothing for now + return + } else { records.append(BalanceService.FetchRequestRecord(address: DependencyManager.shared.selectedWalletAddress ?? "", type: refreshType)) }