immich/web/src/lib/components/user-settings-page/notifications-settings.svelte
waclaw66 dd2c7400a6
chore(web): another missing translations ()
* chore(web): another missing translations

* unused removed

* more keys

* lint fix

* test fixed

* dynamic translation fix

* fixes

* people search translation

* params fixed

* keep filter setting fix

* lint fix

* $t fixes

* Update web/src/lib/i18n/en.json

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>

* another missing

* activity translation

* link sharing translations

* expiration dropdown fix - didn't work localized

* notification title

* device logout

* search results

* reset to default

* unsaved change

* select from computer

* selected

* select-2

* select-3

* unmerge

* pluralize, force icu message

* Update web/src/lib/components/asset-viewer/asset-viewer.svelte

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>

* review fixes

* remove user

* plural fixes

* ffmpeg settings

* fixes

* error title

* plural fixes

* onboarding

* change password

* more more

* console log fix

* another

* api key desc

* map marker

* format fix

* key fix

* asset-utils

* utils

* misc

---------

Co-authored-by: Michel Heusschen <59014050+michelheusschen@users.noreply.github.com>
2024-06-24 09:50:01 -04:00

75 lines
2.8 KiB
Svelte

<script lang="ts">
import {
notificationController,
NotificationType,
} from '$lib/components/shared-components/notification/notification';
import { updateMyPreferences } from '@immich/sdk';
import { fade } from 'svelte/transition';
import { handleError } from '../../utils/handle-error';
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
import { preferences } from '$lib/stores/user.store';
import Button from '../elements/buttons/button.svelte';
import { t } from 'svelte-i18n';
let emailNotificationsEnabled = $preferences?.emailNotifications?.enabled ?? true;
let albumInviteNotificationEnabled = $preferences?.emailNotifications?.albumInvite ?? true;
let albumUpdateNotificationEnabled = $preferences?.emailNotifications?.albumUpdate ?? true;
const handleSave = async () => {
try {
const data = await updateMyPreferences({
userPreferencesUpdateDto: {
emailNotifications: {
enabled: emailNotificationsEnabled,
albumInvite: emailNotificationsEnabled && albumInviteNotificationEnabled,
albumUpdate: emailNotificationsEnabled && albumUpdateNotificationEnabled,
},
},
});
$preferences.emailNotifications.enabled = data.emailNotifications.enabled;
$preferences.emailNotifications.albumInvite = data.emailNotifications.albumInvite;
$preferences.emailNotifications.albumUpdate = data.emailNotifications.albumUpdate;
notificationController.show({ message: $t('saved_settings'), type: NotificationType.Info });
} catch (error) {
handleError(error, $t('errors.unable_to_update_settings'));
}
};
</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
title={$t('notification_toggle_setting_description')}
bind:checked={emailNotificationsEnabled}
/>
</div>
<div class="ml-4">
<SettingSwitch
title={$t('album_added')}
subtitle={$t('album_added_notification_setting_description')}
bind:checked={albumInviteNotificationEnabled}
disabled={!emailNotificationsEnabled}
/>
</div>
<div class="ml-4">
<SettingSwitch
title={$t('album_updated')}
subtitle={$t('album_updated_setting_description')}
bind:checked={albumUpdateNotificationEnabled}
disabled={!emailNotificationsEnabled}
/>
</div>
<div class="flex justify-end">
<Button type="submit" size="sm" on:click={() => handleSave()}>{$t('save')}</Button>
</div>
</div>
</form>
</div>
</section>