From e62071fda09226fbc1ac6ba276112cfe06719754 Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Thu, 19 Jun 2025 17:40:56 +0300 Subject: [PATCH] don't use iterator.find --- .../timeline-manager/internal/search-support.svelte.ts | 2 +- .../managers/timeline-manager/month-group.svelte.ts | 10 +++++++--- .../timeline-manager/timeline-manager.svelte.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/web/src/lib/managers/timeline-manager/internal/search-support.svelte.ts b/web/src/lib/managers/timeline-manager/internal/search-support.svelte.ts index f86e2c1501..50fbf0faab 100644 --- a/web/src/lib/managers/timeline-manager/internal/search-support.svelte.ts +++ b/web/src/lib/managers/timeline-manager/internal/search-support.svelte.ts @@ -32,7 +32,7 @@ export async function getAssetWithOffset( export function findMonthGroupForAsset(timelineManager: TimelineManager, id: string) { for (const month of timelineManager.months) { - const asset = month.findAssetById({ id }); + const asset = month.findAssetById(id); if (asset) { return { monthGroup: month, asset }; } 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 f18a1e6413..f67dbc5b0d 100644 --- a/web/src/lib/managers/timeline-manager/month-group.svelte.ts +++ b/web/src/lib/managers/timeline-manager/month-group.svelte.ts @@ -20,7 +20,7 @@ import { get } from 'svelte/store'; import { DayGroup } from './day-group.svelte'; import { GroupInsertionCache } from './group-insertion-cache.svelte'; import type { TimelineManager } from './timeline-manager.svelte'; -import type { AssetDescriptor, AssetOperation, Direction, MoveAsset, TimelineAsset } from './types'; +import type { AssetOperation, Direction, MoveAsset, TimelineAsset } from './types'; import { ViewerAsset } from './viewer-asset.svelte'; export class MonthGroup { @@ -342,8 +342,12 @@ export class MonthGroup { } } - findAssetById(assetDescriptor: AssetDescriptor) { - return this.assetsIterator().find((asset) => asset.id === assetDescriptor.id); + findAssetById(id: string) { + for (const asset of this.assetsIterator()) { + if (asset.id === id) { + return asset; + } + } } findClosest(target: TimelinePlainDateTime) { diff --git a/web/src/lib/managers/timeline-manager/timeline-manager.svelte.ts b/web/src/lib/managers/timeline-manager/timeline-manager.svelte.ts index 8aacd0a90a..5785224230 100644 --- a/web/src/lib/managers/timeline-manager/timeline-manager.svelte.ts +++ b/web/src/lib/managers/timeline-manager/timeline-manager.svelte.ts @@ -428,7 +428,7 @@ export class TimelineManager { return; } monthGroup = await this.#loadMonthGroupAtTime(asset.localDateTime, { cancelable: false }); - if (monthGroup?.findAssetById({ id })) { + if (monthGroup?.findAssetById(id)) { return monthGroup; } }