mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
perf(web): optimize date groups (#7593)
* optimize date groups * remove `.values()` * remove console.log * remove if condition * remove console.log * remove outdated comment * revert dynamic import
This commit is contained in:
parent
2fa10a254c
commit
762c4684f8
6 changed files with 96 additions and 104 deletions
|
|
@ -1,6 +1,4 @@
|
|||
import { locale } from '$lib/stores/preferences.store';
|
||||
import type { AssetResponseDto } from '@immich/sdk';
|
||||
import { groupBy, sortBy } from 'lodash-es';
|
||||
import { DateTime, Interval } from 'luxon';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
|
|
@ -44,20 +42,11 @@ export function formatGroupTitle(date: DateTime): string {
|
|||
return date.toLocaleString(groupDateFormat);
|
||||
}
|
||||
|
||||
export function splitBucketIntoDateGroups(
|
||||
assets: AssetResponseDto[],
|
||||
locale: string | undefined,
|
||||
): AssetResponseDto[][] {
|
||||
const grouped = groupBy(assets, (asset) =>
|
||||
fromLocalDateTime(asset.localDateTime).toLocaleString(groupDateFormat, { locale }),
|
||||
);
|
||||
return sortBy(grouped, (group) => assets.indexOf(group[0]));
|
||||
}
|
||||
|
||||
export type LayoutBox = {
|
||||
top: number;
|
||||
left: number;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
export function calculateWidth(boxes: LayoutBox[]): number {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue