ソースを参照

Early return on any match

Neeraj Gupta 2 年 前
コミット
b2b5e70790

+ 5 - 6
lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart

@@ -88,20 +88,19 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
   }
   }
 
 
   Future _onReload(FilesUpdatedEvent event) async {
   Future _onReload(FilesUpdatedEvent event) async {
-    final groupDate =
+    final DateTime groupDate =
         DateTime.fromMicrosecondsSinceEpoch(_files[0].creationTime!);
         DateTime.fromMicrosecondsSinceEpoch(_files[0].creationTime!);
-    // iterate over all files and check if any of the belongs to this group
-    final updateFilesBelongingToGroup = event.updatedFiles.where((file) {
+    // iterate over  files and check if any of the belongs to this group
+    final anyCandidateForGroup = event.updatedFiles.any((file) {
       final fileDate = DateTime.fromMicrosecondsSinceEpoch(file.creationTime!);
       final fileDate = DateTime.fromMicrosecondsSinceEpoch(file.creationTime!);
       return fileDate.year == groupDate.year &&
       return fileDate.year == groupDate.year &&
           fileDate.month == groupDate.month &&
           fileDate.month == groupDate.month &&
           fileDate.day == groupDate.day;
           fileDate.day == groupDate.day;
     });
     });
-    if (updateFilesBelongingToGroup.isNotEmpty) {
+    if (anyCandidateForGroup) {
       if (kDebugMode) {
       if (kDebugMode) {
         _logger.info(
         _logger.info(
-          updateFilesBelongingToGroup.length.toString() +
-              " files were updated due to ${event.reason} on " +
+          " files were updated due to ${event.reason} on " +
               DateTime.fromMicrosecondsSinceEpoch(
               DateTime.fromMicrosecondsSinceEpoch(
                 groupDate.microsecondsSinceEpoch,
                 groupDate.microsecondsSinceEpoch,
               ).toIso8601String(),
               ).toIso8601String(),