mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
35 lines
1.1 KiB
Svelte
35 lines
1.1 KiB
Svelte
<script lang="ts">
|
|
import { shortcut } from '$lib/actions/shortcut';
|
|
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
|
import { authManager } from '$lib/managers/auth-manager.svelte';
|
|
import type { Asset } from '$lib/managers/timeline-manager/types';
|
|
import { downloadFile } from '$lib/utils/asset-utils';
|
|
import { getAssetInfo } from '@immich/sdk';
|
|
import { IconButton } from '@immich/ui';
|
|
import { mdiDownload } from '@mdi/js';
|
|
import { t } from 'svelte-i18n';
|
|
|
|
interface Props {
|
|
asset: Asset;
|
|
menuItem?: boolean;
|
|
}
|
|
|
|
let { asset, menuItem = false }: Props = $props();
|
|
|
|
const onDownloadFile = async () => downloadFile(await getAssetInfo({ ...authManager.params, id: asset.id }));
|
|
</script>
|
|
|
|
<svelte:document use:shortcut={{ shortcut: { key: 'd', shift: true }, onShortcut: onDownloadFile }} />
|
|
|
|
{#if !menuItem}
|
|
<IconButton
|
|
color="secondary"
|
|
shape="round"
|
|
variant="ghost"
|
|
icon={mdiDownload}
|
|
aria-label={$t('download')}
|
|
onclick={onDownloadFile}
|
|
/>
|
|
{:else}
|
|
<MenuOption icon={mdiDownload} text={$t('download')} onClick={onDownloadFile} />
|
|
{/if}
|