2024-07-31 18:25:38 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { shortcut } from '$lib/actions/shortcut';
|
|
|
|
|
import MenuOption from '$lib/components/shared-components/context-menu/menu-option.svelte';
|
2025-05-17 22:57:08 -04:00
|
|
|
import { authManager } from '$lib/managers/auth-manager.svelte';
|
2025-06-04 22:27:54 -04:00
|
|
|
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
2024-07-31 18:25:38 +02:00
|
|
|
import { downloadFile } from '$lib/utils/asset-utils';
|
2025-05-17 22:57:08 -04:00
|
|
|
import { getAssetInfo } from '@immich/sdk';
|
2025-06-02 09:47:23 -05:00
|
|
|
import { IconButton } from '@immich/ui';
|
2024-07-31 18:25:38 +02:00
|
|
|
import { mdiFolderDownloadOutline } from '@mdi/js';
|
|
|
|
|
import { t } from 'svelte-i18n';
|
|
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
2025-05-17 22:57:08 -04:00
|
|
|
asset: TimelineAsset;
|
2024-11-14 08:43:25 -06:00
|
|
|
menuItem?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { asset, menuItem = false }: Props = $props();
|
2024-07-31 18:25:38 +02:00
|
|
|
|
2025-05-17 22:57:08 -04:00
|
|
|
const onDownloadFile = async () => downloadFile(await getAssetInfo({ id: asset.id, key: authManager.key }));
|
2024-07-31 18:25:38 +02:00
|
|
|
</script>
|
|
|
|
|
|
2025-05-21 18:12:00 +02:00
|
|
|
<svelte:document use:shortcut={{ shortcut: { key: 'd', shift: true }, onShortcut: onDownloadFile }} />
|
2024-07-31 18:25:38 +02:00
|
|
|
|
|
|
|
|
{#if !menuItem}
|
2025-06-02 09:47:23 -05:00
|
|
|
<IconButton
|
|
|
|
|
color="primary"
|
|
|
|
|
shape="round"
|
|
|
|
|
icon={mdiFolderDownloadOutline}
|
|
|
|
|
aria-label={$t('download')}
|
|
|
|
|
onclick={onDownloadFile}
|
|
|
|
|
/>
|
2024-07-31 18:25:38 +02:00
|
|
|
{:else}
|
|
|
|
|
<MenuOption icon={mdiFolderDownloadOutline} text={$t('download')} onClick={onDownloadFile} />
|
|
|
|
|
{/if}
|