mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
perf(web): speed up multi asset operations (#26217)
This commit is contained in:
parent
d264e78d3f
commit
9ab887d5d2
1 changed files with 8 additions and 12 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue