refactor(web): use callbacks for admin setting events (#10997)

This commit is contained in:
Michel Heusschen
2024-07-10 15:57:18 +02:00
committed by GitHub
parent 545b206076
commit 1dd1d36120
20 changed files with 125 additions and 153 deletions

View File

@@ -1,9 +1,8 @@
<script lang="ts">
import type { SystemConfigDto } from '@immich/sdk';
import { isEqual } from 'lodash-es';
import { createEventDispatcher } from 'svelte';
import { fade } from 'svelte/transition';
import type { SettingsEventType } from '../admin-settings';
import type { SettingsResetEvent, SettingsSaveEvent } from '../admin-settings';
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
import SettingInputField, {
SettingInputFieldType,
@@ -15,8 +14,8 @@
export let defaultConfig: SystemConfigDto;
export let config: SystemConfigDto; // this is the config that is being edited
export let disabled = false;
const dispatch = createEventDispatcher<SettingsEventType>();
export let onReset: SettingsResetEvent;
export let onSave: SettingsSaveEvent;
</script>
<div>
@@ -38,8 +37,8 @@
/>
<SettingButtonsRow
on:reset={({ detail }) => dispatch('reset', { ...detail, configKeys: ['trash'] })}
on:save={() => dispatch('save', { trash: config.trash })}
onReset={(options) => onReset({ ...options, configKeys: ['trash'] })}
onSave={() => onSave({ trash: config.trash })}
showResetToDefault={!isEqual(savedConfig.trash, defaultConfig.trash)}
{disabled}
/>