mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
dev(mobile): Fix freeze bug on app start (#1732)
* Group by date objects instead of strings * Change OpenAPI code generation to wrap json decoding in Change OpenAPI code generation to wrap decodeJson in compute * Remove orig file * Fix linter error * Change drag handle date format * Order timeline explictly from new to old --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
390919c439
commit
6b3892987a
13 changed files with 58 additions and 22 deletions
|
|
@ -75,22 +75,23 @@ class RenderList {
|
|||
|
||||
RenderList(this.elements);
|
||||
|
||||
static Map<String, List<Asset>> _groupAssets(
|
||||
static Map<DateTime, List<Asset>> _groupAssets(
|
||||
List<Asset> assets,
|
||||
GroupAssetsBy groupBy,
|
||||
) {
|
||||
assets.sortByCompare<DateTime>(
|
||||
(e) => e.createdAt,
|
||||
(a, b) => b.compareTo(a),
|
||||
);
|
||||
|
||||
if (groupBy == GroupAssetsBy.day) {
|
||||
return assets.groupListsBy(
|
||||
(element) => DateFormat('y-MM-dd').format(element.createdAt.toLocal()),
|
||||
(element) {
|
||||
final date = element.createdAt.toLocal();
|
||||
return DateTime(date.year, date.month, date.day);
|
||||
},
|
||||
);
|
||||
} else if (groupBy == GroupAssetsBy.month) {
|
||||
return assets.groupListsBy(
|
||||
(element) => DateFormat('y-MM').format(element.createdAt.toLocal()),
|
||||
(element) {
|
||||
final date = element.createdAt.toLocal();
|
||||
return DateTime(date.year, date.month);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -113,10 +114,11 @@ class RenderList {
|
|||
|
||||
final groups = _groupAssets(allAssets, groupBy);
|
||||
|
||||
groups.forEach((groupName, assets) {
|
||||
try {
|
||||
final date = assets.first.createdAt.toLocal();
|
||||
groups.entries.sortedBy((e) =>e.key).reversed.forEach((entry) {
|
||||
final date = entry.key;
|
||||
final assets = entry.value;
|
||||
|
||||
try {
|
||||
// Month title
|
||||
if (groupBy == GroupAssetsBy.day &&
|
||||
(lastDate == null || lastDate!.month != date.month)) {
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ class ImmichAssetGridState extends State<ImmichAssetGrid> {
|
|||
Text _labelBuilder(int pos) {
|
||||
final date = widget.renderList.elements[pos].date;
|
||||
return Text(
|
||||
DateFormat.yMMMd().format(date),
|
||||
DateFormat.yMMMM().format(date),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue