mirror of
https://github.com/immich-app/immich.git
synced 2026-02-28 01:29:04 +03:00
perf(web): speed up multi asset operations (#26217)
This commit is contained in:
@@ -102,25 +102,21 @@ export class DayGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runAssetCallback(ids: Set<string>, callback: (asset: TimelineAsset) => void | { remove?: boolean }) {
|
runAssetCallback(ids: Set<string>, callback: (asset: TimelineAsset) => void | { remove?: boolean }) {
|
||||||
if (ids.size === 0) {
|
|
||||||
return {
|
|
||||||
moveAssets: [] as MoveAsset[],
|
|
||||||
processedIds: new SvelteSet<string>(),
|
|
||||||
unprocessedIds: ids,
|
|
||||||
changedGeometry: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const unprocessedIds = new SvelteSet<string>(ids);
|
const unprocessedIds = new SvelteSet<string>(ids);
|
||||||
const processedIds = new SvelteSet<string>();
|
const processedIds = new SvelteSet<string>();
|
||||||
const moveAssets: MoveAsset[] = [];
|
const moveAssets: MoveAsset[] = [];
|
||||||
let changedGeometry = false;
|
let changedGeometry = false;
|
||||||
for (const assetId of unprocessedIds) {
|
|
||||||
const index = this.viewerAssets.findIndex((viewAsset) => viewAsset.id == assetId);
|
if (ids.size === 0) {
|
||||||
if (index === -1) {
|
return { moveAssets, processedIds, unprocessedIds, changedGeometry };
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let index = this.viewerAssets.length - 1; index >= 0; index--) {
|
||||||
|
const { id: assetId, asset } = this.viewerAssets[index];
|
||||||
|
if (!ids.has(assetId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const asset = this.viewerAssets[index].asset!;
|
|
||||||
const oldTime = { ...asset.localDateTime };
|
const oldTime = { ...asset.localDateTime };
|
||||||
const callbackResult = callback(asset);
|
const callbackResult = callback(asset);
|
||||||
let remove = (callbackResult as { remove?: boolean } | undefined)?.remove ?? false;
|
let remove = (callbackResult as { remove?: boolean } | undefined)?.remove ?? false;
|
||||||
|
|||||||
Reference in New Issue
Block a user