2024-07-31 18:25:38 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { shortcut } from '$lib/actions/shortcut';
|
|
|
|
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
|
|
|
|
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
|
|
|
|
import { downloadFile } from '$lib/utils/asset-utils';
|
|
|
|
|
import type { AssetResponseDto } from '@immich/sdk';
|
|
|
|
|
import { mdiFolderDownloadOutline } from '@mdi/js';
|
|
|
|
|
import { t } from 'svelte-i18n';
|
|
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
asset: AssetResponseDto;
|
|
|
|
|
menuItem?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { asset, menuItem = false }: Props = $props();
|
2024-07-31 18:25:38 +02:00
|
|
|
|
|
|
|
|
const onDownloadFile = () => downloadFile(asset);
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<svelte:window use:shortcut={{ shortcut: { key: 'd', shift: true }, onShortcut: onDownloadFile }} />
|
|
|
|
|
|
|
|
|
|
{#if !menuItem}
|
2024-11-14 08:43:25 -06:00
|
|
|
<CircleIconButton color="opaque" icon={mdiFolderDownloadOutline} title={$t('download')} onclick={onDownloadFile} />
|
2024-07-31 18:25:38 +02:00
|
|
|
{:else}
|
|
|
|
|
<MenuOption icon={mdiFolderDownloadOutline} text={$t('download')} onClick={onDownloadFile} />
|
|
|
|
|
{/if}
|