mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(web): asset viewer actions (#5488)
This commit is contained in:
parent
56aed8246d
commit
22d79850f6
3 changed files with 33 additions and 30 deletions
|
|
@ -128,13 +128,28 @@
|
|||
|
||||
const handleClose = () => assetViewingStore.showAssetViewer(false);
|
||||
|
||||
const handleAction = async (asset: AssetResponseDto, action: AssetAction) => {
|
||||
if (removeAction === action) {
|
||||
// find the next asset to show or close the viewer
|
||||
(await handleNext()) || (await handlePrevious()) || handleClose();
|
||||
const handleAction = async (action: AssetAction, asset: AssetResponseDto) => {
|
||||
switch (action) {
|
||||
case removeAction:
|
||||
case AssetAction.TRASH:
|
||||
case AssetAction.DELETE:
|
||||
// find the next asset to show or close the viewer
|
||||
(await handleNext()) || (await handlePrevious()) || handleClose();
|
||||
|
||||
// delete after find the next one
|
||||
assetStore.removeAsset(asset.id);
|
||||
// delete after find the next one
|
||||
assetStore.removeAsset(asset.id);
|
||||
break;
|
||||
|
||||
case AssetAction.ARCHIVE:
|
||||
case AssetAction.UNARCHIVE:
|
||||
case AssetAction.FAVORITE:
|
||||
case AssetAction.UNFAVORITE:
|
||||
assetStore.updateAsset(asset);
|
||||
break;
|
||||
|
||||
case AssetAction.ADD:
|
||||
assetStore.addAsset(asset);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -402,11 +417,7 @@
|
|||
on:previous={() => handlePrevious()}
|
||||
on:next={() => handleNext()}
|
||||
on:close={() => handleClose()}
|
||||
on:archived={({ detail: asset }) => handleAction(asset, AssetAction.ARCHIVE)}
|
||||
on:unarchived={({ detail: asset }) => handleAction(asset, AssetAction.UNARCHIVE)}
|
||||
on:favorite={({ detail: asset }) => handleAction(asset, AssetAction.FAVORITE)}
|
||||
on:unfavorite={({ detail: asset }) => handleAction(asset, AssetAction.UNFAVORITE)}
|
||||
on:unstack={() => handleClose()}
|
||||
on:action={({ detail: action }) => handleAction(action.type, action.asset)}
|
||||
/>
|
||||
{/if}
|
||||
</Portal>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue