An open-source cross-platform alternative to AirDrop
fix: share intent sometimes not working
Tien Do Nam4a8e5918ce5e
diff --git a/assets/CHANGELOG.md b/assets/CHANGELOG.mdindex 5ada7ccf..65ce3480 100644--- a/assets/CHANGELOG.md+++ b/assets/CHANGELOG.md@@ -1,6 +1,7 @@-## 1.6.1 (2023-01-)+## 1.6.1 (2023-01-27)- fix(windows): app crashes when minimized to tray+- fix: share intent sometimes not working## 1.6.0 (2023-01-27)diff --git a/lib/init.dart b/lib/init.dartindex d24f44dc..ec1903d4 100644--- a/lib/init.dart+++ b/lib/init.dart@@ -31,10 +31,6 @@ Future<PersistenceService> preInit(List<String> args) async {Routerino.transition = RouterinoTransition.cupertino;}- if (checkPlatformWithGallery()) {- clearCache();- }-final persistenceService = await PersistenceService.initialize();final locale = persistenceService.getLocale();@@ -74,10 +70,13 @@ Future<void> postInit(BuildContext context, WidgetRef ref, void Function(int) gocontext.showSnackBar(e.toString());}+ bool hasInitialShare = false;+if (checkPlatformCanReceiveShareIntent()) {final shareHandler = ShareHandlerPlatform.instance;final initialSharedPayload = await shareHandler.getInitialSharedMedia();if (initialSharedPayload != null) {+ hasInitialShare = true;_handleSharedIntent(initialSharedPayload, ref);goToPage(HomeTab.send.index);}@@ -88,6 +87,12 @@ Future<void> postInit(BuildContext context, WidgetRef ref, void Function(int) gogoToPage(HomeTab.send.index);});}++ if (!hasInitialShare && (checkPlatformWithGallery() || checkPlatformCanReceiveShareIntent())) {+ // Clear cache on every app start.+ // If we received a share intent, then don't clear it, otherwise the shared file will be lost.+ clearCache();+ }}void _handleSharedIntent(SharedMedia payload, WidgetRef ref) {