diff --git a/web/src/lib/managers/timeline-manager/day-group.svelte.ts b/web/src/lib/managers/timeline-manager/day-group.svelte.ts index e2c124e54c..3a05c0664f 100644 --- a/web/src/lib/managers/timeline-manager/day-group.svelte.ts +++ b/web/src/lib/managers/timeline-manager/day-group.svelte.ts @@ -31,7 +31,9 @@ export class DayGroup { this.monthGroup = monthGroup; this.day = day; this.groupTitle = groupTitle; - onCreateDayGroup(this); + if (import.meta.env.DEV) { + onCreateDayGroup(this); + } } get top() { diff --git a/web/src/lib/managers/timeline-manager/group-insertion-cache.svelte.ts b/web/src/lib/managers/timeline-manager/group-insertion-cache.svelte.ts index aa4bae8919..566b11b8b7 100644 --- a/web/src/lib/managers/timeline-manager/group-insertion-cache.svelte.ts +++ b/web/src/lib/managers/timeline-manager/group-insertion-cache.svelte.ts @@ -1,6 +1,5 @@ import { setDifference, type TimelineDate } from '$lib/utils/timeline-util'; import { AssetOrder } from '@immich/sdk'; -import { SvelteSet } from 'svelte/reactivity'; import type { DayGroup } from './day-group.svelte'; import type { MonthGroup } from './month-group.svelte'; import type { TimelineAsset } from './types'; @@ -10,8 +9,10 @@ export class GroupInsertionCache { [year: number]: { [month: number]: { [day: number]: DayGroup } }; } = {}; unprocessedAssets: TimelineAsset[] = []; - changedDayGroups = new SvelteSet(); - newDayGroups = new SvelteSet(); + // eslint-disable-next-line svelte/prefer-svelte-reactivity + changedDayGroups = new Set(); + // eslint-disable-next-line svelte/prefer-svelte-reactivity + newDayGroups = new Set(); getDayGroup({ year, month, day }: TimelineDate): DayGroup | undefined { return this.#lookupCache[year]?.[month]?.[day]; @@ -32,7 +33,8 @@ export class GroupInsertionCache { } get updatedBuckets() { - const updated = new SvelteSet(); + // eslint-disable-next-line svelte/prefer-svelte-reactivity + const updated = new Set(); for (const group of this.changedDayGroups) { updated.add(group.monthGroup); } @@ -40,7 +42,8 @@ export class GroupInsertionCache { } get bucketsWithNewDayGroups() { - const updated = new SvelteSet(); + // eslint-disable-next-line svelte/prefer-svelte-reactivity + const updated = new Set(); for (const group of this.newDayGroups) { updated.add(group.monthGroup); } diff --git a/web/src/lib/managers/timeline-manager/internal/load-support.svelte.ts b/web/src/lib/managers/timeline-manager/internal/load-support.svelte.ts index e6a80afc7f..70b41462b9 100644 --- a/web/src/lib/managers/timeline-manager/internal/load-support.svelte.ts +++ b/web/src/lib/managers/timeline-manager/internal/load-support.svelte.ts @@ -43,7 +43,7 @@ export async function loadFromTimeBuckets( } } - const unprocessedAssets = monthGroup.addAssets(bucketResponse); + const unprocessedAssets = monthGroup.addAssets(bucketResponse, true); if (unprocessedAssets.length > 0) { console.error( `Warning: getTimeBucket API returning assets not in requested month: ${monthGroup.yearMonth.month}, ${JSON.stringify( diff --git a/web/src/lib/managers/timeline-manager/month-group.svelte.ts b/web/src/lib/managers/timeline-manager/month-group.svelte.ts index 12b054c69c..6ad74d4577 100644 --- a/web/src/lib/managers/timeline-manager/month-group.svelte.ts +++ b/web/src/lib/managers/timeline-manager/month-group.svelte.ts @@ -76,7 +76,9 @@ export class MonthGroup { if (loaded) { this.isLoaded = true; } - onCreateMonthGroup(this); + if (import.meta.env.DEV) { + onCreateMonthGroup(this); + } } set intersecting(newValue: boolean) { @@ -161,7 +163,7 @@ export class MonthGroup { }; } - addAssets(bucketAssets: TimeBucketAssetResponseDto) { + addAssets(bucketAssets: TimeBucketAssetResponseDto, preSorted: boolean) { const addContext = new GroupInsertionCache(); for (let i = 0; i < bucketAssets.id.length; i++) { const { localDateTime, fileCreatedAt } = getTimes( @@ -202,17 +204,17 @@ export class MonthGroup { } this.addTimelineAsset(timelineAsset, addContext); } + if (!preSorted) { + for (const group of addContext.existingDayGroups) { + group.sortAssets(this.#sortOrder); + } - for (const group of addContext.existingDayGroups) { - group.sortAssets(this.#sortOrder); + if (addContext.newDayGroups.size > 0) { + this.sortDayGroups(); + } + + addContext.sort(this, this.#sortOrder); } - - if (addContext.newDayGroups.size > 0) { - this.sortDayGroups(); - } - - addContext.sort(this, this.#sortOrder); - return addContext.unprocessedAssets; }