An open-source cross-platform alternative to AirDrop
Delete from history through file not found dialogue
TheGB0077e1b28ccae25a
diff --git a/lib/pages/receive_history_page.dart b/lib/pages/receive_history_page.dartindex 0e62e1de..59ae79b6 100644--- a/lib/pages/receive_history_page.dart+++ b/lib/pages/receive_history_page.dart@@ -36,9 +36,9 @@ final _optionsWithoutOpen = [_EntryOption.info, _EntryOption.delete];class ReceiveHistoryPage extends ConsumerWidget {const ReceiveHistoryPage({Key? key}) : super(key: key);- Future<void> _openFile(BuildContext context, ReceiveHistoryEntry entry) async {+ Future<void> _openFile(BuildContext context, ReceiveHistoryEntry entry, ReceiveHistoryNotifier filesRef) async {if (entry.path != null) {- openFile(context, entry.fileType, entry.path!);+ openFile(context, entry.fileType, entry.path!, entry.id, filesRef);}}@@ -90,7 +90,7 @@ class ReceiveHistoryPage extends ConsumerWidget {splashFactory: NoSplash.splashFactory,highlightColor: Colors.transparent,hoverColor: Colors.transparent,- onTap: entry.path != null ? () => _openFile(context, entry) : null,+ onTap: entry.path != null ? () => _openFile(context, entry, ref.read(receiveHistoryProvider.notifier)) : null,child: Row(crossAxisAlignment: CrossAxisAlignment.start,children: [@@ -126,7 +126,7 @@ class ReceiveHistoryPage extends ConsumerWidget {onSelected: (_EntryOption item) {switch (item) {case _EntryOption.open:- _openFile(context, entry);+ _openFile(context, entry, ref.read(receiveHistoryProvider.notifier));break;case _EntryOption.info:showDialog(diff --git a/lib/util/native/open_file.dart b/lib/util/native/open_file.dartindex 135c9e79..0839a22c 100644--- a/lib/util/native/open_file.dart+++ b/lib/util/native/open_file.dart@@ -4,14 +4,15 @@ import 'package:localsend_app/util/platform_check.dart';import 'package:localsend_app/widget/dialogs/cannot_open_file_dialog.dart';import 'package:open_filex/open_filex.dart';import 'package:permission_handler/permission_handler.dart';+import '../../provider/receive_history_provider.dart';/// Opens the selected file which is stored on the device.-Future<void> openFile(BuildContext context, FileType fileType, String filePath) async {+Future<void> openFile(BuildContext context, FileType fileType, String filePath, [String? fileId, ReceiveHistoryNotifier? filesRef]) async {if ((fileType == FileType.apk || filePath.toLowerCase().endsWith('.apk')) && checkPlatform([TargetPlatform.android])) {await Permission.requestInstallPackages.request();}final fileOpenResult = await OpenFilex.open(filePath);if (fileOpenResult.type != ResultType.done && context.mounted) {- CannotOpenFileDialog.open(context, filePath);+ CannotOpenFileDialog.open(context, filePath, fileId, filesRef);}}\ No newline at end of filediff --git a/lib/widget/dialogs/cannot_open_file_dialog.dart b/lib/widget/dialogs/cannot_open_file_dialog.dartindex 8cdd81b1..1163928a 100644--- a/lib/widget/dialogs/cannot_open_file_dialog.dart+++ b/lib/widget/dialogs/cannot_open_file_dialog.dart@@ -3,13 +3,14 @@ import 'package:localsend_app/gen/strings.g.dart';import 'package:localsend_app/util/platform_check.dart';import 'package:localsend_app/widget/dialogs/custom_bottom_sheet.dart';import 'package:routerino/routerino.dart';+import '../../provider/receive_history_provider.dart';class CannotOpenFileDialog extends StatelessWidget {final String path;const CannotOpenFileDialog({required this.path, super.key});- static void open(BuildContext context, String path) {+ static void open(BuildContext context, String path, String? fileId, ReceiveHistoryNotifier? filesRef) {if (checkPlatformIsDesktop()) {showDialog(context: context,@@ -17,6 +18,10 @@ class CannotOpenFileDialog extends StatelessWidget {title: Text(t.dialogs.cannotOpenFile.title),content: Text(t.dialogs.cannotOpenFile.content(file: path)),actions: [+ TextButton(+ onPressed: () => { filesRef!.removeEntry(fileId!), context.pop() },+ child: Text(t.receiveHistoryPage.entryActions.deleteFromHistory),+ ),TextButton(onPressed: () => context.pop(),child: Text(t.general.close),