Skip to content

Commit

Permalink
optimize list
Browse files Browse the repository at this point in the history
  • Loading branch information
karlprieb committed Jan 17, 2024
1 parent 009aa85 commit 69607cd
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions lib/blocs/drive_detail/drive_detail_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -461,27 +461,17 @@ class DriveDetailCubit extends Cubit<DriveDetailState> {

final isShowingHiddenFiles = state.isShowingHiddenFiles;

final List<FileDataTableItem> allImagesForFolder;
if (isShowingHiddenFiles) {
allImagesForFolder = state.currentFolderContents
.whereType<FileDataTableItem>()
.where(
(element) => supportedImageTypesInFilePreview.contains(
element.contentType,
),
)
.toList();
} else {
allImagesForFolder = state.currentFolderContents
.whereType<FileDataTableItem>()
.where(
(element) => supportedImageTypesInFilePreview.contains(
element.contentType,
),
)
.where((e) => !e.isHidden)
.toList();
}
final List<FileDataTableItem> allImagesForFolder =
state.currentFolderContents.whereType<FileDataTableItem>().where(
(element) {
final supportedImageType = supportedImageTypesInFilePreview.contains(
element.contentType,
);

return supportedImageType &&
(isShowingHiddenFiles ? true : !element.isHidden);
},
).toList();

_allImagesOfCurrentFolder = allImagesForFolder;

Expand Down

0 comments on commit 69607cd

Please sign in to comment.