mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-12 01:50:15 +02:00
Remove download notification when download fails
This commit is contained in:
@@ -145,6 +145,9 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<DownloadedApk> downloadApp(App app, BuildContext? context) async {
|
Future<DownloadedApk> downloadApp(App app, BuildContext? context) async {
|
||||||
|
NotificationsProvider? notificationsProvider =
|
||||||
|
context?.read<NotificationsProvider>();
|
||||||
|
var notifId = DownloadNotification(app.name, 0).id;
|
||||||
if (apps[app.id] != null) {
|
if (apps[app.id] != null) {
|
||||||
apps[app.id]!.downloadProgress = 0;
|
apps[app.id]!.downloadProgress = 0;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -155,8 +158,6 @@ class AppsProvider with ChangeNotifier {
|
|||||||
String downloadUrl = await SourceProvider()
|
String downloadUrl = await SourceProvider()
|
||||||
.getSource(app.url)
|
.getSource(app.url)
|
||||||
.apkUrlPrefetchModifier(app.apkUrls[app.preferredApkIndex]);
|
.apkUrlPrefetchModifier(app.apkUrls[app.preferredApkIndex]);
|
||||||
NotificationsProvider? notificationsProvider =
|
|
||||||
context?.read<NotificationsProvider>();
|
|
||||||
var notif = DownloadNotification(app.name, 100);
|
var notif = DownloadNotification(app.name, 100);
|
||||||
notificationsProvider?.cancel(notif.id);
|
notificationsProvider?.cancel(notif.id);
|
||||||
int? prevProg;
|
int? prevProg;
|
||||||
@@ -173,7 +174,6 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
prevProg = prog;
|
prevProg = prog;
|
||||||
});
|
});
|
||||||
notificationsProvider?.cancel(notif.id);
|
|
||||||
// Delete older versions of the APK if any
|
// Delete older versions of the APK if any
|
||||||
for (var file in downloadedFile.parent.listSync()) {
|
for (var file in downloadedFile.parent.listSync()) {
|
||||||
var fn = file.path.split('/').last;
|
var fn = file.path.split('/').last;
|
||||||
@@ -201,6 +201,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
return DownloadedApk(app.id, downloadedFile);
|
return DownloadedApk(app.id, downloadedFile);
|
||||||
} finally {
|
} finally {
|
||||||
|
notificationsProvider?.cancel(notifId);
|
||||||
if (apps[app.id] != null) {
|
if (apps[app.id] != null) {
|
||||||
apps[app.id]!.downloadProgress = null;
|
apps[app.id]!.downloadProgress = null;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
Reference in New Issue
Block a user