2023-08-09 22:01:16 -04:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {
|
|
|
|
|
notificationController,
|
|
|
|
|
NotificationType,
|
|
|
|
|
} from '$lib/components/shared-components/notification/notification';
|
2024-05-27 22:16:53 -04:00
|
|
|
import { updateMyPreferences } from '@immich/sdk';
|
2023-08-09 22:01:16 -04:00
|
|
|
import { fade } from 'svelte/transition';
|
|
|
|
|
import { handleError } from '../../utils/handle-error';
|
2024-02-22 15:36:14 +01:00
|
|
|
|
|
|
|
|
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
|
2024-05-27 22:16:53 -04:00
|
|
|
import { preferences } from '$lib/stores/user.store';
|
2024-05-26 18:15:52 -04:00
|
|
|
import Button from '../elements/buttons/button.svelte';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2023-08-09 22:01:16 -04:00
|
|
|
|
2024-05-27 22:16:53 -04:00
|
|
|
let memoriesEnabled = $preferences?.memories?.enabled ?? false;
|
2023-08-09 22:01:16 -04:00
|
|
|
|
|
|
|
|
const handleSave = async () => {
|
|
|
|
|
try {
|
2024-05-27 22:16:53 -04:00
|
|
|
const data = await updateMyPreferences({ userPreferencesUpdateDto: { memories: { enabled: memoriesEnabled } } });
|
|
|
|
|
$preferences.memories.enabled = data.memories.enabled;
|
2023-08-09 22:01:16 -04:00
|
|
|
|
2024-06-04 21:53:00 +02:00
|
|
|
notificationController.show({ message: $t('saved_settings'), type: NotificationType.Info });
|
2023-08-09 22:01:16 -04:00
|
|
|
} catch (error) {
|
2024-06-04 21:53:00 +02:00
|
|
|
handleError(error, $t('errors.unable_to_update_settings'));
|
2023-08-09 22:01:16 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<section class="my-4">
|
|
|
|
|
<div in:fade={{ duration: 500 }}>
|
|
|
|
|
<form autocomplete="off" on:submit|preventDefault>
|
|
|
|
|
<div class="ml-4 mt-4 flex flex-col gap-4">
|
|
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('time_based_memories')}
|
|
|
|
|
subtitle={$t('photos_from_previous_years')}
|
2024-05-27 22:16:53 -04:00
|
|
|
bind:checked={memoriesEnabled}
|
2023-08-09 22:01:16 -04:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex justify-end">
|
2024-06-04 21:53:00 +02:00
|
|
|
<Button type="submit" size="sm" on:click={() => handleSave()}>{$t('save')}</Button>
|
2023-08-09 22:01:16 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|