mirror of
https://github.com/immich-app/immich.git
synced 2024-12-26 10:50:29 +02:00
fix(mobile) invalid date in exif cause timeline to crash (#1095)
This commit is contained in:
parent
1efcac0946
commit
2edbf64e69
@ -1,6 +1,9 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:immich_mobile/shared/models/asset.dart';
|
import 'package:immich_mobile/shared/models/asset.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
|
final log = Logger('AssetGridDataStructure');
|
||||||
|
|
||||||
enum RenderAssetGridElementType {
|
enum RenderAssetGridElementType {
|
||||||
assetRow,
|
assetRow,
|
||||||
@ -64,46 +67,50 @@ List<RenderAssetGridElement> assetGroupsToRenderList(
|
|||||||
DateTime? lastDate;
|
DateTime? lastDate;
|
||||||
|
|
||||||
assetGroups.forEach((groupName, assets) {
|
assetGroups.forEach((groupName, assets) {
|
||||||
final date = DateTime.parse(groupName);
|
try {
|
||||||
|
final date = DateTime.parse(groupName);
|
||||||
|
|
||||||
if (lastDate == null || lastDate!.month != date.month) {
|
if (lastDate == null || lastDate!.month != date.month) {
|
||||||
|
elements.add(
|
||||||
|
RenderAssetGridElement(
|
||||||
|
RenderAssetGridElementType.monthTitle,
|
||||||
|
title: groupName,
|
||||||
|
date: date,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add group title
|
||||||
elements.add(
|
elements.add(
|
||||||
RenderAssetGridElement(
|
RenderAssetGridElement(
|
||||||
RenderAssetGridElementType.monthTitle,
|
RenderAssetGridElementType.dayTitle,
|
||||||
title: groupName,
|
title: groupName,
|
||||||
date: date,
|
date: date,
|
||||||
),
|
relatedAssetList: assets,
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add group title
|
|
||||||
elements.add(
|
|
||||||
RenderAssetGridElement(
|
|
||||||
RenderAssetGridElementType.dayTitle,
|
|
||||||
title: groupName,
|
|
||||||
date: date,
|
|
||||||
relatedAssetList: assets,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add rows
|
|
||||||
int cursor = 0;
|
|
||||||
while (cursor < assets.length) {
|
|
||||||
int rowElements = min(assets.length - cursor, assetsPerRow);
|
|
||||||
|
|
||||||
final rowElement = RenderAssetGridElement(
|
|
||||||
RenderAssetGridElementType.assetRow,
|
|
||||||
date: date,
|
|
||||||
assetRow: RenderAssetGridRow(
|
|
||||||
assets.sublist(cursor, cursor + rowElements),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
elements.add(rowElement);
|
// Add rows
|
||||||
cursor += rowElements;
|
int cursor = 0;
|
||||||
}
|
while (cursor < assets.length) {
|
||||||
|
int rowElements = min(assets.length - cursor, assetsPerRow);
|
||||||
|
|
||||||
lastDate = date;
|
final rowElement = RenderAssetGridElement(
|
||||||
|
RenderAssetGridElementType.assetRow,
|
||||||
|
date: date,
|
||||||
|
assetRow: RenderAssetGridRow(
|
||||||
|
assets.sublist(cursor, cursor + rowElements),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
elements.add(rowElement);
|
||||||
|
cursor += rowElements;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastDate = date;
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
log.severe(e, stackTrace);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return elements;
|
return elements;
|
||||||
|
Loading…
Reference in New Issue
Block a user