Skip to content

Commit 14bbd4c

Browse files
committed
- cleanup
1 parent bc8d72b commit 14bbd4c

File tree

3 files changed

+21
-79
lines changed

3 files changed

+21
-79
lines changed

web/src/lib/components/photos-page/asset-grid.svelte

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@
2626
import { searchStore } from '$lib/stores/search.svelte';
2727
import { featureFlags } from '$lib/stores/server-config.store';
2828
import { handlePromiseError } from '$lib/utils';
29-
import {
30-
deleteAssets,
31-
refreshStackedAssetInTimeline,
32-
updateStackedAssetInTimeline,
33-
updateUnstackedAssetInTimeline,
34-
} from '$lib/utils/actions';
29+
import { deleteAssets } from '$lib/utils/actions';
3530
import { archiveAssets, cancelMultiselect, selectAllAssets, stackAssets } from '$lib/utils/asset-utils';
3631
import { navigate } from '$lib/utils/navigation';
3732
import {
@@ -421,7 +416,7 @@
421416
const onStackAssets = async () => {
422417
const result = await stackAssets(assetInteraction.selectedAssets);
423418
424-
timelineManager.stackAssets(result);//updateStackedAssetInTimeline(timelineManager, result);
419+
timelineManager.stackAssets(result); //updateStackedAssetInTimeline(timelineManager, result);
425420
426421
onEscape();
427422
};
@@ -525,18 +520,18 @@
525520
}
526521
527522
case AssetAction.UNSTACK: {
528-
timelineManager.unstackAssets(action.assets);//updateUnstackedAssetInTimeline(timelineManager, action.assets);
523+
timelineManager.unstackAssets(action.assets);
529524
break;
530525
}
531526
case AssetAction.REMOVE_ASSET_FROM_STACK: {
532527
timelineManager.addAssets([toTimelineAsset(action.asset)]);
533528
if (action.stack) {
534-
timelineManager.refreshStack(action.stack)//refreshStackedAssetInTimeline(timelineManager, action.stack);
529+
timelineManager.refreshStack(action.stack);
535530
}
536531
break;
537532
}
538533
case AssetAction.SET_STACK_PRIMARY_ASSET: {
539-
timelineManager.refreshStack(action.stack, true);//refreshStackedAssetInTimeline(timelineManager, action.stack, true);
534+
timelineManager.refreshStack(action.stack, true);
540535
break;
541536
}
542537
}

web/src/lib/managers/timeline-manager/timeline-manager.svelte.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,13 @@ export class TimelineManager {
546546
return this.#options.order ?? AssetOrder.Desc;
547547
}
548548

549+
/**
550+
* Update the asset stack state in the asset store based on the provided stack response.
551+
* This function updates the stack information so that the icon is shown for the primary asset
552+
* and removes any assets from the timeline that are marked for deletion.
553+
*
554+
* @param {StackResponse} stackResponse - The stack response containing the stack and assets to delete.
555+
*/
549556
stackAssets({ stack, toDeleteIds }: StackResponse) {
550557
if (stack) {
551558
this.updateAssetOperation([stack.primaryAssetId], (asset) => {
@@ -560,6 +567,14 @@ export class TimelineManager {
560567
}
561568
}
562569

570+
/**
571+
* Update the timeline manager to reflect the unstacked state of assets.
572+
* This function updates the stack property of each asset to undefined, effectively unstacking them.
573+
* It also adds the unstacked assets back to the timeline manager.
574+
*
575+
* @param timelineManager - The timeline manager to update.
576+
* @param assets - The array of asset response DTOs to update in the timeline manager.
577+
*/
563578
unstackAssets(assets: TimelineAsset[]) {
564579
this.updateAssetOperation(
565580
assets.map(({ id }) => id),

web/src/lib/utils/actions.ts

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { notificationController, NotificationType } from '$lib/components/shared-components/notification/notification';
2-
import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
32
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
43
import type { StackResponse } from '$lib/utils/asset-utils';
5-
import { toTimelineAsset } from '$lib/utils/timeline-util';
6-
import { AssetVisibility, deleteAssets as deleteBulk, restoreAssets, type StackResponseDto } from '@immich/sdk';
4+
import { AssetVisibility, deleteAssets as deleteBulk, restoreAssets } from '@immich/sdk';
75
import { t } from 'svelte-i18n';
86
import { get } from 'svelte/store';
97
import { handleError } from './handle-error';
@@ -58,69 +56,3 @@ const undoDeleteAssets = async (onUndoDelete: OnUndoDelete, assets: TimelineAsse
5856
handleError(error, $t('errors.unable_to_restore_assets'));
5957
}
6058
};
61-
62-
/**
63-
* Update the asset stack state in the asset store based on the provided stack response.
64-
* This function updates the stack information so that the icon is shown for the primary asset
65-
* and removes any assets from the timeline that are marked for deletion.
66-
*
67-
* @param {TimelineManager} timelineManager - The timeline manager to update.
68-
* @param {StackResponse} stackResponse - The stack response containing the stack and assets to delete.
69-
*/
70-
export function updateStackedAssetInTimeline(timelineManager: TimelineManager, { stack, toDeleteIds }: StackResponse) {
71-
if (stack != undefined) {
72-
timelineManager.updateAssetOperation([stack.primaryAssetId], (asset) => {
73-
asset.stack = {
74-
id: stack.id,
75-
primaryAssetId: stack.primaryAssetId,
76-
assetCount: stack.assets.length,
77-
};
78-
return { remove: false };
79-
});
80-
81-
timelineManager.removeAssets(toDeleteIds);
82-
}
83-
}
84-
85-
/**
86-
* Update the timeline manager to reflect the unstacked state of assets.
87-
* This function updates the stack property of each asset to undefined, effectively unstacking them.
88-
* It also adds the unstacked assets back to the timeline manager.
89-
*
90-
* @param timelineManager - The timeline manager to update.
91-
* @param assets - The array of asset response DTOs to update in the timeline manager.
92-
*/
93-
export function updateUnstackedAssetInTimeline(timelineManager: TimelineManager, assets: TimelineAsset[]) {
94-
timelineManager.updateAssetOperation(
95-
assets.map((asset) => asset.id),
96-
(asset) => {
97-
asset.stack = null;
98-
return { remove: false };
99-
},
100-
);
101-
102-
timelineManager.addAssets(assets);
103-
}
104-
105-
export function refreshStackedAssetInTimeline(
106-
timelineManager: TimelineManager,
107-
stack: StackResponseDto,
108-
addPrimaryAsset: boolean = false,
109-
) {
110-
if (stack != undefined) {
111-
if (addPrimaryAsset) {
112-
timelineManager.addAssets(
113-
stack.assets.filter((a) => a.id === stack.primaryAssetId).map((a) => toTimelineAsset(a)),
114-
);
115-
}
116-
timelineManager.updateAssetOperation([stack.primaryAssetId], (asset) => {
117-
asset.stack = {
118-
id: stack.id,
119-
primaryAssetId: stack.primaryAssetId,
120-
assetCount: stack.assets.length,
121-
};
122-
return { remove: false };
123-
});
124-
timelineManager.removeAssets(stack.assets.filter((a) => a.id !== stack.primaryAssetId).map(({ id }) => id));
125-
}
126-
}

0 commit comments

Comments
 (0)