Browse Source

Merge pull request #773 from ente-io/fix_custom_time_bug

Minor bug fixes
Neeraj Gupta 2 years ago
parent
commit
3b8e98dba7

+ 17 - 6
lib/ui/sharing/manage_links_widget.dart

@@ -304,10 +304,13 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
                   CupertinoButton(
                   CupertinoButton(
                     onPressed: () async {
                     onPressed: () async {
                       int newValidTill = -1;
                       int newValidTill = -1;
+                      bool hasSelectedCustom = false;
                       final int expireAfterInMicroseconds =
                       final int expireAfterInMicroseconds =
                           _selectedExpiry.item3;
                           _selectedExpiry.item3;
                       // need to manually select time
                       // need to manually select time
                       if (expireAfterInMicroseconds < 0) {
                       if (expireAfterInMicroseconds < 0) {
+                        hasSelectedCustom = true;
+                        Navigator.of(context).pop('');
                         final timeInMicrosecondsFromEpoch =
                         final timeInMicrosecondsFromEpoch =
                             await _showDateTimePicker();
                             await _showDateTimePicker();
                         if (timeInMicrosecondsFromEpoch != null) {
                         if (timeInMicrosecondsFromEpoch != null) {
@@ -320,14 +323,12 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
                         newValidTill = DateTime.now().microsecondsSinceEpoch +
                         newValidTill = DateTime.now().microsecondsSinceEpoch +
                             expireAfterInMicroseconds;
                             expireAfterInMicroseconds;
                       }
                       }
+                      if (!hasSelectedCustom) {
+                        Navigator.of(context).pop('');
+                      }
                       if (newValidTill >= 0) {
                       if (newValidTill >= 0) {
-                        await _updateUrlSettings(
-                          context,
-                          {'validTill': newValidTill},
-                        );
-                        setState(() {});
+                        await updateTime(newValidTill);
                       }
                       }
-                      Navigator.of(context).pop('');
                     },
                     },
                     padding: const EdgeInsets.symmetric(
                     padding: const EdgeInsets.symmetric(
                       horizontal: 16.0,
                       horizontal: 16.0,
@@ -368,6 +369,16 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
     );
     );
   }
   }
 
 
+  Future<void> updateTime(int newValidTill) async {
+    await _updateUrlSettings(
+      context,
+      {'validTill': newValidTill},
+    );
+    if(mounted) {
+      setState(() {});
+    }
+  }
+
   // _showDateTimePicker return null if user doesn't select date-time
   // _showDateTimePicker return null if user doesn't select date-time
   Future<int?> _showDateTimePicker() async {
   Future<int?> _showDateTimePicker() async {
     final dateResult = await DatePicker.showDatePicker(
     final dateResult = await DatePicker.showDatePicker(

+ 1 - 1
lib/ui/viewer/file/detail_page.dart

@@ -303,7 +303,7 @@ class _DetailPageState extends State<DetailPage> {
         return;
         return;
       }
       }
       final imageProvider =
       final imageProvider =
-          ExtendedFileImageProvider(ioFile!, cacheRawData: true);
+          ExtendedFileImageProvider(ioFile, cacheRawData: true);
       await precacheImage(imageProvider, context);
       await precacheImage(imageProvider, context);
       await dialog.hide();
       await dialog.hide();
       replacePage(
       replacePage(

+ 1 - 1
lib/utils/toast_util.dart

@@ -31,7 +31,7 @@ Future showToast(
       ..loadingStyle = EasyLoadingStyle.custom;
       ..loadingStyle = EasyLoadingStyle.custom;
     return EasyLoading.showToast(
     return EasyLoading.showToast(
       message,
       message,
-      duration: Duration(seconds: (toastLength == Toast.LENGTH_LONG ? 5 : 1),
+      duration: Duration(seconds: (toastLength == Toast.LENGTH_LONG ? 5 : 1)),
       toastPosition: EasyLoadingToastPosition.bottom,
       toastPosition: EasyLoadingToastPosition.bottom,
       dismissOnTap: iOSDismissOnTap,
       dismissOnTap: iOSDismissOnTap,
     );
     );