improve download handling

This commit is contained in:
Fabian Freund
2026-05-26 06:23:31 +02:00
parent 038cb3dffc
commit da90d07318
13 changed files with 3803 additions and 2425 deletions
@@ -45,6 +45,7 @@ import 'package:weblibre/presentation/hooks/menu_controller.dart';
import 'package:weblibre/presentation/widgets/failure_widget.dart';
import 'package:weblibre/presentation/widgets/uri_breadcrumb.dart';
import 'package:weblibre/presentation/widgets/url_icon.dart';
import 'package:weblibre/utils/ui_helper.dart' as ui_helper;
class Section extends MultiSliver {
static final _datePattern = DateFormat.MMMd().addPattern('Hm');
@@ -499,6 +500,34 @@ class HistoryScreen extends HookConsumerWidget {
onTap: (item) async {
if (selectedItems.value.isNotEmpty) {
toggleSelected(item);
} else if (isDownloadsMode) {
final filePath = item.title;
final file = filePath.mapNotNull(File.new);
if (file == null ||
await file.exists() != true) {
if (context.mounted) {
ui_helper.showErrorMessage(
context,
'Downloaded file not found',
);
}
return;
}
final opened = await GeckoDownloadsService()
.openDownloadedFile(
fileName: p.basename(file.path),
directoryPath: file.parent.path,
contentType: item.previewImageUrl,
);
if (!opened && context.mounted) {
ui_helper.showErrorMessage(
context,
'Could not open downloaded file',
);
}
} else {
await ref
.read(tabRepositoryProvider.notifier)
@@ -441,7 +441,7 @@ final class UnifiedPreferenceSettingsRepositoryProvider
}
String _$unifiedPreferenceSettingsRepositoryHash() =>
r'c544b5815ec676ddb6cde1ffeb8c9ef4a7dc4469';
r'f2153c826e2cba308cf3e8bdfe371e0b6b3e7dbd';
final class UnifiedPreferenceSettingsRepositoryFamily extends $Family
with
@@ -554,7 +554,7 @@ final class PreferenceSettingsGroupRepositoryProvider
}
String _$preferenceSettingsGroupRepositoryHash() =>
r'c8335b39c4c9fa95c4d415231b103a2feff97d26';
r'ae2b8553b895945d2a5c44a8ed24b8bbb00bb985';
final class PreferenceSettingsGroupRepositoryFamily extends $Family
with