2024-02-28 22:39:53 +01:00
|
|
|
<script lang="ts">
|
2024-05-23 19:56:48 +02:00
|
|
|
import { autoGrowHeight } from '$lib/actions/autogrow';
|
2024-02-28 22:39:53 +01:00
|
|
|
import { updateAlbumInfo } from '@immich/sdk';
|
|
|
|
|
import { handleError } from '$lib/utils/handle-error';
|
2024-05-23 19:56:48 +02:00
|
|
|
import { shortcut } from '$lib/actions/shortcut';
|
2024-02-28 22:39:53 +01:00
|
|
|
|
|
|
|
|
export let id: string;
|
|
|
|
|
export let description: string;
|
|
|
|
|
export let isOwned: boolean;
|
|
|
|
|
|
|
|
|
|
$: newDescription = description;
|
|
|
|
|
|
|
|
|
|
const handleUpdateDescription = async () => {
|
|
|
|
|
if (newDescription === description) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await updateAlbumInfo({
|
|
|
|
|
id,
|
|
|
|
|
updateAlbumDto: {
|
|
|
|
|
description: newDescription,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleError(error, 'Error updating album description');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
description = newDescription;
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if isOwned}
|
|
|
|
|
<textarea
|
2024-04-16 01:37:47 +02:00
|
|
|
class="w-full mt-2 resize-none text-black dark:text-white border-b-2 border-transparent border-gray-500 bg-transparent text-base outline-none transition-all focus:border-b-2 focus:border-immich-primary disabled:border-none dark:focus:border-immich-dark-primary hover:border-gray-400"
|
2024-02-28 22:39:53 +01:00
|
|
|
bind:value={newDescription}
|
|
|
|
|
on:input={(e) => autoGrowHeight(e.currentTarget)}
|
|
|
|
|
on:focusout={handleUpdateDescription}
|
|
|
|
|
use:autoGrowHeight
|
2024-04-05 21:19:26 +02:00
|
|
|
placeholder="Add a description"
|
2024-03-15 00:16:55 +01:00
|
|
|
use:shortcut={{
|
|
|
|
|
shortcut: { key: 'Enter', ctrl: true },
|
|
|
|
|
onShortcut: (e) => e.currentTarget.blur(),
|
|
|
|
|
}}
|
2024-02-28 22:39:53 +01:00
|
|
|
/>
|
|
|
|
|
{:else if description}
|
|
|
|
|
<p class="break-words whitespace-pre-line w-full text-black dark:text-white text-base">
|
|
|
|
|
{description}
|
|
|
|
|
</p>
|
|
|
|
|
{/if}
|