use a better variable name

This commit is contained in:
ashilkn 2024-01-29 15:04:21 +05:30
parent 89e1b78f44
commit cbdcac4440

View file

@ -56,7 +56,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
late Logger _logger;
late List<EnteFile> _files;
late List<EnteFile> _filesInGroup;
late StreamSubscription<FilesUpdatedEvent>? _reloadEventSubscription;
late StreamSubscription<int> _currentIndexSubscription;
bool? _shouldRender;
@ -75,7 +75,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
void _init() {
_logger = Logger("LazyLoading_${widget.logTag}");
_shouldRender = true;
_files = widget.files;
_filesInGroup = widget.files;
_areAllFromGroupSelectedNotifier.value = _areAllFromGroupSelected();
_reloadEventSubscription = widget.reloadEvent?.listen((e) => _onReload(e));
@ -101,11 +101,11 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
}
Future _onReload(FilesUpdatedEvent event) async {
if (_files.isEmpty) {
if (_filesInGroup.isEmpty) {
return;
}
final DateTime groupDate =
DateTime.fromMicrosecondsSinceEpoch(_files[0].creationTime!);
DateTime.fromMicrosecondsSinceEpoch(_filesInGroup[0].creationTime!);
// 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!);
@ -147,7 +147,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
final galleryState = context.findAncestorStateOfType<GalleryState>();
if (galleryState?.mounted ?? false) {
galleryState!.setState(() {});
_files = result.files;
_filesInGroup = result.files;
}
} else if (kDebugMode) {
debugPrint("Unexpected event ${event.type.name}");
@ -167,7 +167,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
@override
void didUpdateWidget(LazyGroupGallery oldWidget) {
super.didUpdateWidget(oldWidget);
if (!listEquals(_files, widget.files)) {
if (!listEquals(_filesInGroup, widget.files)) {
_reloadEventSubscription?.cancel();
_init();
}
@ -175,7 +175,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
@override
Widget build(BuildContext context) {
if (_files.isEmpty) {
if (_filesInGroup.isEmpty) {
return const SizedBox.shrink();
}
return Column(
@ -185,7 +185,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
children: [
if (widget.enableFileGrouping)
GroupHeaderWidget(
timestamp: _files[0].creationTime!,
timestamp: _filesInGroup[0].creationTime!,
gridSize: widget.photoGridSize,
),
Expanded(child: Container()),
@ -221,7 +221,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
),
onTap: () {
widget.selectedFiles?.toggleGroupSelection(
_files.toSet(),
_filesInGroup.toSet(),
);
},
);
@ -232,7 +232,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
_shouldRender!
? GroupGallery(
photoGridSize: widget.photoGridSize,
files: _files,
files: _filesInGroup,
tag: widget.tag,
asyncLoader: widget.asyncLoader,
selectedFiles: widget.selectedFiles,
@ -241,7 +241,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
// todo: perf eval should we have separate PlaceHolder for Groups
// instead of creating a large cached view
: PlaceHolderGridViewWidget(
_files.length,
_filesInGroup.length,
widget.photoGridSize,
),
],
@ -251,7 +251,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
void _selectedFilesListener() {
if (widget.selectedFiles == null) return;
_areAllFromGroupSelectedNotifier.value =
widget.selectedFiles!.files.containsAll(_files.toSet());
widget.selectedFiles!.files.containsAll(_filesInGroup.toSet());
//Can remove this if we decide to show select all by default for all galleries
if (widget.selectedFiles!.files.isEmpty && !widget.showSelectAllByDefault) {