From 4db33bef8b7a8b8e39ee03def55595e8eceb456d Mon Sep 17 00:00:00 2001 From: Abhishek Shroff Date: Thu, 1 May 2025 13:06:40 +0530 Subject: [PATCH] [client] Fix share intent handling on cold start --- client/lib/ui/explorer/explorer_view.dart | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/client/lib/ui/explorer/explorer_view.dart b/client/lib/ui/explorer/explorer_view.dart index fe25f4cb..9537aa18 100644 --- a/client/lib/ui/explorer/explorer_view.dart +++ b/client/lib/ui/explorer/explorer_view.dart @@ -34,22 +34,20 @@ class _ExplorerViewState extends State { void initState() { super.initState(); - // Listen to media sharing coming from outside the app while the app is in the memory. + // Process share intents received while the app is alive _intentSub = ReceiveSharingIntent.instance.getMediaStream().listen((value) { - final files = value.map((f) => f.path).toList(growable: false); - handleShareIntent(files).then((value) => ReceiveSharingIntent.instance.reset()); - }, onError: (err) { - print("getIntentDataStream error: $err"); + handleShareIntent(value).then((value) => ReceiveSharingIntent.instance.reset()); }); - // Get the media sharing coming from outside the app while the app is closed. + // Process share intents received while the app is closed ReceiveSharingIntent.instance.getInitialMedia().then((value) { - final files = value.map((f) => f.path).toList(growable: false); - handleShareIntent(files).then((value) => ReceiveSharingIntent.instance.reset()); + handleShareIntent(value).then((value) => ReceiveSharingIntent.instance.reset()); }); } - Future handleShareIntent(List paths) async { + Future handleShareIntent(List files) async { + if (files.isEmpty) return; + final paths = files.map((f) => f.path).toList(growable: false); final account = context.read(); final dest = await DestinationPicker.show(context, account.userHome, allowInitialFolder: true); if (dest == null) {