Skip App loading on return to foreground

This commit is contained in:
Imran Remtulla
2023-05-22 12:10:58 -04:00
parent ca1371260c
commit 4136734a60
2 changed files with 9 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ class NavigationPageItem {
class _HomePageState extends State<HomePage> {
List<int> selectedIndexHistory = [];
int prevAppCount = -1;
bool prevIsLoading = true;
List<NavigationPageItem> pages = [
NavigationPageItem(tr('appsString'), Icons.apps,
@@ -64,13 +65,15 @@ class _HomePageState extends State<HomePage> {
}
}
if (prevAppCount >= 0 &&
if (!prevIsLoading &&
prevAppCount >= 0 &&
appsProvider.apps.length > prevAppCount &&
selectedIndexHistory.isNotEmpty &&
selectedIndexHistory.last == 1) {
switchToPage(0);
}
prevAppCount = appsProvider.apps.length;
prevIsLoading = appsProvider.loadingApps;
return WillPopScope(
child: Scaffold(

View File

@@ -116,7 +116,7 @@ class AppsProvider with ChangeNotifier {
foregroundStream = FGBGEvents.stream.asBroadcastStream();
foregroundSubscription = foregroundStream?.listen((event) async {
isForeground = event == FGBGType.foreground;
if (isForeground) await loadApps();
if (isForeground) await refreshInstallStatuses();
});
() async {
// Load Apps into memory (in background, this is done later instead of in the constructor)
@@ -747,6 +747,10 @@ class AppsProvider with ChangeNotifier {
}
loadingApps = false;
notifyListeners();
refreshInstallStatuses();
}
Future<void> refreshInstallStatuses() async {
if (await doesInstalledAppsPluginWork()) {
List<App> modifiedApps = [];
for (var app in apps.values) {