mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-18 20:49:30 +02:00
Skip App loading on return to foreground
This commit is contained in:
@@ -27,6 +27,7 @@ class NavigationPageItem {
|
|||||||
class _HomePageState extends State<HomePage> {
|
class _HomePageState extends State<HomePage> {
|
||||||
List<int> selectedIndexHistory = [];
|
List<int> selectedIndexHistory = [];
|
||||||
int prevAppCount = -1;
|
int prevAppCount = -1;
|
||||||
|
bool prevIsLoading = true;
|
||||||
|
|
||||||
List<NavigationPageItem> pages = [
|
List<NavigationPageItem> pages = [
|
||||||
NavigationPageItem(tr('appsString'), Icons.apps,
|
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 &&
|
appsProvider.apps.length > prevAppCount &&
|
||||||
selectedIndexHistory.isNotEmpty &&
|
selectedIndexHistory.isNotEmpty &&
|
||||||
selectedIndexHistory.last == 1) {
|
selectedIndexHistory.last == 1) {
|
||||||
switchToPage(0);
|
switchToPage(0);
|
||||||
}
|
}
|
||||||
prevAppCount = appsProvider.apps.length;
|
prevAppCount = appsProvider.apps.length;
|
||||||
|
prevIsLoading = appsProvider.loadingApps;
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
@@ -116,7 +116,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
foregroundStream = FGBGEvents.stream.asBroadcastStream();
|
foregroundStream = FGBGEvents.stream.asBroadcastStream();
|
||||||
foregroundSubscription = foregroundStream?.listen((event) async {
|
foregroundSubscription = foregroundStream?.listen((event) async {
|
||||||
isForeground = event == FGBGType.foreground;
|
isForeground = event == FGBGType.foreground;
|
||||||
if (isForeground) await loadApps();
|
if (isForeground) await refreshInstallStatuses();
|
||||||
});
|
});
|
||||||
() async {
|
() async {
|
||||||
// Load Apps into memory (in background, this is done later instead of in the constructor)
|
// 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;
|
loadingApps = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
refreshInstallStatuses();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> refreshInstallStatuses() async {
|
||||||
if (await doesInstalledAppsPluginWork()) {
|
if (await doesInstalledAppsPluginWork()) {
|
||||||
List<App> modifiedApps = [];
|
List<App> modifiedApps = [];
|
||||||
for (var app in apps.values) {
|
for (var app in apps.values) {
|
||||||
|
Reference in New Issue
Block a user