mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-10-24 19:33:45 +02:00
Attempt to improve load times again + link parsing bugfix (#1625)
This commit is contained in:
@@ -368,7 +368,10 @@ 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) loadApps();
|
if (isForeground) {
|
||||||
|
await loadApps(andUpdateSuperficialDetails: false);
|
||||||
|
updateAppsSuperficialDetails();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
() async {
|
() async {
|
||||||
await settingsProvider.initializeSettings();
|
await settingsProvider.initializeSettings();
|
||||||
@@ -384,7 +387,9 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
if (!isBg) {
|
if (!isBg) {
|
||||||
// Load Apps into memory (in background processes, this is done later instead of in the constructor)
|
// Load Apps into memory (in background processes, this is done later instead of in the constructor)
|
||||||
await loadApps();
|
await loadApps(andUpdateSuperficialDetails: false);
|
||||||
|
// Update app names/icons asynchronously
|
||||||
|
updateAppsSuperficialDetails();
|
||||||
// Delete any partial APKs (if safe to do so)
|
// Delete any partial APKs (if safe to do so)
|
||||||
var cutoff = DateTime.now().subtract(const Duration(days: 7));
|
var cutoff = DateTime.now().subtract(const Duration(days: 7));
|
||||||
APKDir.listSync()
|
APKDir.listSync()
|
||||||
@@ -1176,7 +1181,24 @@ class AppsProvider with ChangeNotifier {
|
|||||||
app.name;
|
app.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadApps({String? singleId}) async {
|
Future<void> updateAppsSuperficialDetails() async {
|
||||||
|
await Future.wait(apps.values.map((app) async {
|
||||||
|
var icon = await app.installedInfo?.applicationInfo?.getAppIcon();
|
||||||
|
app.app.name =
|
||||||
|
await (app.installedInfo?.applicationInfo?.getAppLabel()) ??
|
||||||
|
app.app.name;
|
||||||
|
// Update the app in memory with install info and corrections
|
||||||
|
apps.update(
|
||||||
|
app.app.id,
|
||||||
|
(value) => AppInMemory(
|
||||||
|
app.app, value.downloadProgress, app.installedInfo, icon),
|
||||||
|
ifAbsent: () => AppInMemory(app.app, null, app.installedInfo, icon));
|
||||||
|
notifyListeners();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadApps(
|
||||||
|
{String? singleId, bool andUpdateSuperficialDetails = true}) async {
|
||||||
while (loadingApps) {
|
while (loadingApps) {
|
||||||
await Future.delayed(const Duration(microseconds: 1));
|
await Future.delayed(const Duration(microseconds: 1));
|
||||||
}
|
}
|
||||||
@@ -1234,22 +1256,21 @@ class AppsProvider with ChangeNotifier {
|
|||||||
removedAppIds.add(moddedApp.id);
|
removedAppIds.add(moddedApp.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var icon = await installedInfo?.applicationInfo?.getAppIcon();
|
|
||||||
app.name =
|
|
||||||
await (installedInfo?.applicationInfo?.getAppLabel()) ?? app.name;
|
|
||||||
// Update the app in memory with install info and corrections
|
// Update the app in memory with install info and corrections
|
||||||
apps.update(
|
apps.update(
|
||||||
app.id,
|
app.id,
|
||||||
(value) => AppInMemory(
|
(value) => AppInMemory(
|
||||||
app!, value.downloadProgress, installedInfo, icon),
|
app!, value.downloadProgress, installedInfo, value.icon),
|
||||||
ifAbsent: () => AppInMemory(app!, null, installedInfo, icon));
|
ifAbsent: () => AppInMemory(app!, null, installedInfo, null));
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errors.add([app!.id, app.finalName, e.toString()]);
|
errors.add([app!.id, app.finalName, e.toString()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
if (andUpdateSuperficialDetails) {
|
||||||
|
await updateAppsSuperficialDetails();
|
||||||
|
}
|
||||||
if (errors.isNotEmpty) {
|
if (errors.isNotEmpty) {
|
||||||
removeApps(errors.map((e) => e[0]).toList());
|
removeApps(errors.map((e) => e[0]).toList());
|
||||||
NotificationsProvider().notify(
|
NotificationsProvider().notify(
|
||||||
|
|||||||
@@ -354,11 +354,13 @@ preStandardizeUrl(String url) {
|
|||||||
url.toLowerCase().indexOf('https://') != 0) {
|
url.toLowerCase().indexOf('https://') != 0) {
|
||||||
url = 'https://$url';
|
url = 'https://$url';
|
||||||
}
|
}
|
||||||
|
var trailingSlash = Uri.tryParse(url)?.path.endsWith('/') ?? false;
|
||||||
url = url
|
url = url
|
||||||
.split('/')
|
.split('/')
|
||||||
.where((e) => e.isNotEmpty)
|
.where((e) => e.isNotEmpty)
|
||||||
.join('/')
|
.join('/')
|
||||||
.replaceFirst(':/', '://');
|
.replaceFirst(':/', '://') +
|
||||||
|
(trailingSlash ? '/' : '');
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,8 +525,7 @@ abstract class AppSource {
|
|||||||
[GeneratedFormTextField('appName', label: tr('appName'), required: false)],
|
[GeneratedFormTextField('appName', label: tr('appName'), required: false)],
|
||||||
[
|
[
|
||||||
GeneratedFormSwitch('shizukuPretendToBeGooglePlay',
|
GeneratedFormSwitch('shizukuPretendToBeGooglePlay',
|
||||||
label: tr('shizukuPretendToBeGooglePlay'),
|
label: tr('shizukuPretendToBeGooglePlay'), defaultValue: false)
|
||||||
defaultValue: false)
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
GeneratedFormSwitch('exemptFromBackgroundUpdates',
|
GeneratedFormSwitch('exemptFromBackgroundUpdates',
|
||||||
|
|||||||
Reference in New Issue
Block a user