refactor(web): consolidate asset operations in PhotostreamManager base class

Moves common asset operation methods (upsertAssets, removeAssets, 
updateAssetOperation) from TimelineManager into PhotostreamManager 
base class, making them available to all photostream implementations. 
Updates all consuming components to use the more accurate 'upsertAssets' 
naming instead of separate 'addAssets' and 'updateAssets' methods.

- Move asset operation methods to PhotostreamManager base class
- Replace addAssets/updateAssets calls with unified upsertAssets method
- Update type imports to use PhotostreamManager instead of TimelineManager
- Remove operations-support.svelte.ts (functionality moved to base class)
- Add abstract upsertAssetIntoSegment method for subclass customization
This commit is contained in:
midzelis 2025-09-29 12:03:39 +00:00
parent 98ab224791
commit c44b315117
16 changed files with 230 additions and 207 deletions

View file

@ -111,12 +111,12 @@
case AssetAction.UNARCHIVE:
case AssetAction.FAVORITE:
case AssetAction.UNFAVORITE: {
timelineManager.updateAssets([action.asset]);
timelineManager.upsertAssets([action.asset]);
break;
}
case AssetAction.ADD: {
timelineManager.addAssets([action.asset]);
timelineManager.upsertAssets([action.asset]);
break;
}
@ -125,7 +125,7 @@
break;
}
case AssetAction.REMOVE_ASSET_FROM_STACK: {
timelineManager.addAssets([toTimelineAsset(action.asset)]);
timelineManager.upsertAssets([toTimelineAsset(action.asset)]);
if (action.stack) {
//Have to unstack then restack assets in timeline in order to update the stack count in the timeline.
updateUnstackedAssetInTimeline(

View file

@ -1,6 +1,6 @@
<script lang="ts">
import { getAssetControlContext } from '$lib/components/timeline/AssetSelectControlBar.svelte';
import type { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
import type { PhotostreamManager } from '$lib/managers/photostream-manager/PhotostreamManager.svelte';
import type { OnArchive } from '$lib/utils/actions';
import { archiveAssets } from '$lib/utils/asset-utils';
import { AssetVisibility } from '@immich/sdk';
@ -13,7 +13,7 @@
onArchive?: OnArchive;
menuItem?: boolean;
unarchive?: boolean;
manager?: TimelineManager;
manager?: PhotostreamManager;
}
let { onArchive, menuItem = false, unarchive = false, manager }: Props = $props();

View file

@ -1,7 +1,7 @@
<script lang="ts">
import DeleteAssetDialog from '$lib/components/photos-page/delete-asset-dialog.svelte';
import { getAssetControlContext } from '$lib/components/timeline/AssetSelectControlBar.svelte';
import { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
import type { PhotostreamManager } from '$lib/managers/photostream-manager/PhotostreamManager.svelte';
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
import { featureFlags } from '$lib/stores/server-config.store';
import { type OnDelete, type OnUndoDelete, deleteAssets } from '$lib/utils/actions';
@ -15,7 +15,7 @@
onUndoDelete?: OnUndoDelete;
menuItem?: boolean;
force?: boolean;
manager?: TimelineManager;
manager?: PhotostreamManager;
}
let { onAssetDelete, onUndoDelete, menuItem = false, force = !$featureFlags.trash, manager }: Props = $props();
@ -40,7 +40,7 @@
loading = true;
const assets = [...getOwnedAssets()];
const undo = (assets: TimelineAsset[]) => {
manager?.addAssets(assets);
manager?.upsertAssets(assets);
onUndoDelete?.(assets);
};
await deleteAssets(force, onAssetDelete, assets, undo);

View file

@ -5,7 +5,7 @@
notificationController,
} from '$lib/components/shared-components/notification/notification';
import { getAssetControlContext } from '$lib/components/timeline/AssetSelectControlBar.svelte';
import type { TimelineManager } from '$lib/managers/timeline-manager/timeline-manager.svelte';
import type { PhotostreamManager } from '$lib/managers/photostream-manager/PhotostreamManager.svelte';
import type { OnFavorite } from '$lib/utils/actions';
import { handleError } from '$lib/utils/handle-error';
import { updateAssets } from '@immich/sdk';
@ -17,7 +17,7 @@
onFavorite?: OnFavorite;
menuItem?: boolean;
removeFavorite: boolean;
manager?: TimelineManager;
manager?: PhotostreamManager;
}
let { onFavorite, menuItem = false, removeFavorite, manager }: Props = $props();

View file

@ -51,7 +51,7 @@
!(isTrashEnabled && !force),
(assetIds) => timelineManager.removeAssets(assetIds),
assetInteraction.selectedAssets,
!isTrashEnabled || force ? undefined : (assets) => timelineManager.addAssets(assets),
!isTrashEnabled || force ? undefined : (assets) => timelineManager.upsertAssets(assets),
);
assetInteraction.clearMultiselect();
};