mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(web): manually link live photos (#12514)
feat(web,server): manually link live photos
This commit is contained in:
parent
12bfb19852
commit
27050af57b
16 changed files with 178 additions and 36 deletions
|
|
@ -0,0 +1,44 @@
|
|||
<script lang="ts">
|
||||
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
||||
import type { OnLink } from '$lib/utils/actions';
|
||||
import { AssetTypeEnum, updateAsset } from '@immich/sdk';
|
||||
import { mdiMotionPlayOutline, mdiTimerSand } from '@mdi/js';
|
||||
import { t } from 'svelte-i18n';
|
||||
import MenuOption from '../../shared-components/context-menu/menu-option.svelte';
|
||||
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
||||
|
||||
export let onLink: OnLink;
|
||||
export let menuItem = false;
|
||||
|
||||
let loading = false;
|
||||
|
||||
const text = $t('link_motion_video');
|
||||
const icon = mdiMotionPlayOutline;
|
||||
|
||||
const { clearSelect, getOwnedAssets } = getAssetControlContext();
|
||||
|
||||
const handleLink = async () => {
|
||||
let [still, motion] = [...getOwnedAssets()];
|
||||
if (still.type === AssetTypeEnum.Video) {
|
||||
[still, motion] = [motion, still];
|
||||
}
|
||||
|
||||
loading = true;
|
||||
const response = await updateAsset({ id: still.id, updateAssetDto: { livePhotoVideoId: motion.id } });
|
||||
onLink(response);
|
||||
clearSelect();
|
||||
loading = false;
|
||||
};
|
||||
</script>
|
||||
|
||||
{#if menuItem}
|
||||
<MenuOption {text} {icon} onClick={handleLink} />
|
||||
{/if}
|
||||
|
||||
{#if !menuItem}
|
||||
{#if loading}
|
||||
<CircleIconButton title={$t('loading')} icon={mdiTimerSand} />
|
||||
{:else}
|
||||
<CircleIconButton title={text} {icon} on:click={handleLink} />
|
||||
{/if}
|
||||
{/if}
|
||||
Loading…
Add table
Add a link
Reference in a new issue