Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix error

ashilkn88aa5fbfe108
diff --git a/mobile/apps/photos/lib/models/gallery/gallery_sections.dart b/mobile/apps/photos/lib/models/gallery/gallery_sections.dart
index 257411ff06..32ad4f03d8 100644
--- a/mobile/apps/photos/lib/models/gallery/gallery_sections.dart
+++ b/mobile/apps/photos/lib/models/gallery/gallery_sections.dart
@@ -59,7 +59,7 @@ class GalleryGroups {
final List<String> _groupIds = [];
final Map<String, List<EnteFile>> _groupIdToFilesMap = {};
- final Map<String, GroupType> _groupIdToGroupTypeDataMap = {};
+ final Map<String, GroupType> _groupIdToGroupDataMap = {};
final Map<double, String> _scrollOffsetToGroupIdMap = {};
final Map<String, double> _groupIdToScrollOffsetMap = {};
final List<double> _groupScrollOffsets = [];
@@ -69,8 +69,7 @@ class GalleryGroups {
List<String> get groupIDs => _groupIds;
Map<String, List<EnteFile>> get groupIDToFilesMap => _groupIdToFilesMap;
- Map<String, GroupType> get groupIdToGroupTypeMap =>
- _groupIdToGroupTypeDataMap;
+ Map<String, GroupType> get groupIdToGroupDataMap => _groupIdToGroupDataMap;
Map<double, String> get scrollOffsetToGroupIdMap => _scrollOffsetToGroupIdMap;
Map<String, double> get groupIdToScrollOffsetMap => _groupIdToScrollOffsetMap;
List<FixedExtentSectionLayout> get groupLayouts => _groupLayouts;
@@ -83,7 +82,7 @@ class GalleryGroups {
_buildGroups();
_groupLayouts = _computeGroupLayouts();
assert(groupIDs.length == _groupIdToFilesMap.length);
- assert(groupIDs.length == _groupIdToGroupTypeDataMap.length);
+ assert(groupIDs.length == _groupIdToGroupDataMap.length);
assert(
groupIDs.length == _scrollOffsetToGroupIdMap.length,
);
@@ -113,7 +112,7 @@ class GalleryGroups {
final maxOffset = minOffset +
(numberOfGridRows * tileHeight) +
(numberOfGridRows - 1) * spacing +
- groupHeaderExtent;
+ groupHeaderExtent!;
final bodyFirstIndex = firstIndex + 1;
groupLayouts.add(
@@ -122,14 +121,14 @@ class GalleryGroups {
lastIndex: lastIndex,
minOffset: minOffset,
maxOffset: maxOffset,
- headerExtent: groupHeaderExtent,
+ headerExtent: groupHeaderExtent!,
tileHeight: tileHeight,
spacing: spacing,
builder: (context, rowIndex) {
if (rowIndex == firstIndex) {
if (showGroupHeader) {
return GroupHeaderWidget(
- title: _groupIdToGroupTypeDataMap[groupID]!
+ title: _groupIdToGroupDataMap[groupID]!
.getTitle(context, groupIDToFilesMap[groupID]!.first),
gridSize: crossAxisCount,
filesInGroup: groupIDToFilesMap[groupID]!,
@@ -269,7 +268,7 @@ class GalleryGroups {
final uuid = _uuid.v1();
_groupIds.add(uuid);
_groupIdToFilesMap[uuid] = groupFiles;
- _groupIdToGroupTypeDataMap[uuid] = groupType;
+ _groupIdToGroupDataMap[uuid] = groupType;
// For scrollbar divisions
if (groupType.timeGrouping()) {
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index f218fda072..eb61106173 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -188,7 +188,6 @@ class GalleryState extends State<Gallery> {
}
if (!hasTriggeredSetState && mounted) {
_updateGalleryGroups();
- setState(() {});
}
});
});
@@ -248,10 +247,12 @@ class GalleryState extends State<Gallery> {
).then((size) {
setState(() {
groupHeaderExtent = size.height;
+ _updateGalleryGroups(callSetState: false);
});
});
} else {
groupHeaderExtent = GalleryGroups.spacing;
+ _updateGalleryGroups();
}
WidgetsBinding.instance.addPostFrameCallback((_) async {
@@ -287,7 +288,8 @@ class GalleryState extends State<Gallery> {
}
}
- void _updateGalleryGroups() {
+ void _updateGalleryGroups({bool callSetState = true}) {
+ if (groupHeaderExtent == null) return;
galleryGroups = GalleryGroups(
allFiles: _allGalleryFiles,
groupType: _groupType,
@@ -295,9 +297,13 @@ class GalleryState extends State<Gallery> {
widthAvailable: MediaQuery.sizeOf(context).width,
selectedFiles: widget.selectedFiles,
tagPrefix: widget.tagPrefix,
- groupHeaderExtent: groupHeaderExtent,
+ groupHeaderExtent: groupHeaderExtent!,
showSelectAll: widget.showSelectAll,
);
+
+ if (callSetState) {
+ setState(() {});
+ }
}
void _selectedFilesListener() {
@@ -323,7 +329,6 @@ class GalleryState extends State<Gallery> {
final hasReloaded = _onFilesLoaded(files);
if (!hasReloaded && mounted) {
_updateGalleryGroups();
- setState(() {});
}
}
@@ -545,7 +550,8 @@ class GalleryState extends State<Gallery> {
// widget.showSelectAllByDefault && widget.groupType.showGroupHeader(),
// isScrollablePositionedList: widget.isScrollablePositionedList,
// ),
- child: _allGalleryFiles.isEmpty
+
+ child: _hasLoadedFiles && _allGalleryFiles.isEmpty
? Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -859,8 +865,8 @@ class _PinnedGroupHeaderState extends State<PinnedGroupHeader> {
child: ColoredBox(
color: getEnteColorScheme(context).backgroundBase,
child: GroupHeaderWidget(
- title: widget.galleryGroups
- .groupIdToGroupDataMap[currentGroupId!]!.groupType
+ title: widget
+ .galleryGroups.groupIdToGroupDataMap[currentGroupId!]!
.getTitle(
context,
widget.galleryGroups.groupIDToFilesMap[currentGroupId]!