mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 01:11:46 +03:00
29 lines
1.1 KiB
Svelte
29 lines
1.1 KiB
Svelte
|
|
<script lang="ts">
|
||
|
|
import { shortcut } from '$lib/actions/shortcut';
|
||
|
|
import type { OnAction } from '$lib/components/asset-viewer/actions/action';
|
||
|
|
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
||
|
|
import { AssetAction } from '$lib/constants';
|
||
|
|
import { toggleArchive } from '$lib/utils/asset-utils';
|
||
|
|
import type { AssetResponseDto } from '@immich/sdk';
|
||
|
|
import { mdiArchiveArrowDownOutline, mdiArchiveArrowUpOutline } from '@mdi/js';
|
||
|
|
import { t } from 'svelte-i18n';
|
||
|
|
|
||
|
|
export let asset: AssetResponseDto;
|
||
|
|
export let onAction: OnAction;
|
||
|
|
|
||
|
|
const onArchive = async () => {
|
||
|
|
const updatedAsset = await toggleArchive(asset);
|
||
|
|
if (updatedAsset) {
|
||
|
|
onAction({ type: asset.isArchived ? AssetAction.ARCHIVE : AssetAction.UNARCHIVE, asset });
|
||
|
|
}
|
||
|
|
};
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<svelte:window use:shortcut={{ shortcut: { key: 'a', shift: true }, onShortcut: onArchive }} />
|
||
|
|
|
||
|
|
<MenuOption
|
||
|
|
icon={asset.isArchived ? mdiArchiveArrowUpOutline : mdiArchiveArrowDownOutline}
|
||
|
|
text={asset.isArchived ? $t('unarchive') : $t('to_archive')}
|
||
|
|
onClick={onArchive}
|
||
|
|
/>
|