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:
Matthias Rupp 2023-02-12 04:37:48 +01:00 committed by GitHub
parent 390919c439
commit 6b3892987a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 58 additions and 22 deletions

View file

@ -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)) {

View file

@ -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,