mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-10-29 20:43:28 +01:00
Fix missing update button bug (perform full load on foreground)
This commit is contained in:
@@ -117,7 +117,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 refreshInstallStatuses();
|
if (isForeground) await loadApps();
|
||||||
});
|
});
|
||||||
() async {
|
() async {
|
||||||
var cacheDirs = await getExternalCacheDirectories();
|
var cacheDirs = await getExternalCacheDirectories();
|
||||||
@@ -744,47 +744,35 @@ class AppsProvider with ChangeNotifier {
|
|||||||
// Put Apps into memory to list them (fast)
|
// Put Apps into memory to list them (fast)
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
try {
|
try {
|
||||||
apps[app.id] = AppInMemory(app, null, null);
|
sp.getSource(app.url, overrideSource: app.overrideSource);
|
||||||
|
apps.update(
|
||||||
|
app.id,
|
||||||
|
(value) =>
|
||||||
|
AppInMemory(app, value.downloadProgress, value.installedInfo),
|
||||||
|
ifAbsent: () => AppInMemory(app, null, null));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errors.add([app.id, app.finalName, e.toString()]);
|
errors.add([app.id, app.finalName, e.toString()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
for (var app in newApps) {
|
|
||||||
// Check install status for each App (slow)
|
|
||||||
if (app != null) {
|
|
||||||
try {
|
|
||||||
apps[app.id]?.installedInfo = await getInstalledInfo(app.id);
|
|
||||||
sp.getSource(app.url, overrideSource: app.overrideSource);
|
|
||||||
} catch (e) {
|
|
||||||
apps.remove(app.id);
|
|
||||||
errors.add([app.id, app.finalName, e.toString()]);
|
|
||||||
}
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (errors.isNotEmpty) {
|
if (errors.isNotEmpty) {
|
||||||
removeApps(errors.map((e) => e[0]).toList());
|
removeApps(errors.map((e) => e[0]).toList());
|
||||||
NotificationsProvider().notify(
|
NotificationsProvider().notify(
|
||||||
AppsRemovedNotification(errors.map((e) => [e[1], e[2]]).toList()));
|
AppsRemovedNotification(errors.map((e) => [e[1], e[2]]).toList()));
|
||||||
}
|
}
|
||||||
loadingApps = false;
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
refreshInstallStatuses(useExistingInstalledInfo: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> refreshInstallStatuses(
|
|
||||||
{bool useExistingInstalledInfo = false}) async {
|
|
||||||
if (await doesInstalledAppsPluginWork()) {
|
if (await doesInstalledAppsPluginWork()) {
|
||||||
|
for (var app in apps.values) {
|
||||||
|
// Check install status for each App (slow)
|
||||||
|
apps[app.app.id]?.installedInfo = await getInstalledInfo(app.app.id);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
// Reconcile version differences
|
||||||
List<App> modifiedApps = [];
|
List<App> modifiedApps = [];
|
||||||
for (var app in apps.values) {
|
for (var app in apps.values) {
|
||||||
var moddedApp = getCorrectedInstallStatusAppIfPossible(
|
var moddedApp =
|
||||||
app.app,
|
getCorrectedInstallStatusAppIfPossible(app.app, app.installedInfo);
|
||||||
useExistingInstalledInfo
|
|
||||||
? app.installedInfo
|
|
||||||
: await getInstalledInfo(app.app.id));
|
|
||||||
if (moddedApp != null) {
|
if (moddedApp != null) {
|
||||||
modifiedApps.add(moddedApp);
|
modifiedApps.add(moddedApp);
|
||||||
}
|
}
|
||||||
@@ -795,6 +783,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
.where((a) => a.installedVersion == null)
|
.where((a) => a.installedVersion == null)
|
||||||
.map((e) => e.id)
|
.map((e) => e.id)
|
||||||
.toList();
|
.toList();
|
||||||
|
// After reconciliation, delete externally uninstalled Apps if needed
|
||||||
if (removedAppIds.isNotEmpty) {
|
if (removedAppIds.isNotEmpty) {
|
||||||
var settingsProvider = SettingsProvider();
|
var settingsProvider = SettingsProvider();
|
||||||
await settingsProvider.initializeSettings();
|
await settingsProvider.initializeSettings();
|
||||||
@@ -804,6 +793,9 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadingApps = false;
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> saveApps(List<App> apps,
|
Future<void> saveApps(List<App> apps,
|
||||||
|
|||||||
Reference in New Issue
Block a user