mirror of
https://github.com/immich-app/immich.git
synced 2025-12-18 17:23:16 +03:00
refactor(web): asset viewer actions (#5488)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user