mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(web): migrate away from event dispatcher (#12802)
This commit is contained in:
parent
cfc575d89c
commit
94fc1f213a
18 changed files with 76 additions and 123 deletions
|
|
@ -3,28 +3,24 @@
|
|||
import ConfirmDialog from '$lib/components/shared-components/dialog/confirm-dialog.svelte';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { restoreUserAdmin, type UserResponseDto } from '@immich/sdk';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { t } from 'svelte-i18n';
|
||||
|
||||
export let user: UserResponseDto;
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
success: void;
|
||||
fail: void;
|
||||
cancel: void;
|
||||
}>();
|
||||
export let onSuccess: () => void;
|
||||
export let onFail: () => void;
|
||||
export let onCancel: () => void;
|
||||
|
||||
const handleRestoreUser = async () => {
|
||||
try {
|
||||
const { deletedAt } = await restoreUserAdmin({ id: user.id });
|
||||
if (deletedAt == undefined) {
|
||||
dispatch('success');
|
||||
onSuccess();
|
||||
} else {
|
||||
dispatch('fail');
|
||||
onFail();
|
||||
}
|
||||
} catch (error) {
|
||||
handleError(error, $t('errors.unable_to_restore_user'));
|
||||
dispatch('fail');
|
||||
onFail();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -34,7 +30,7 @@
|
|||
confirmText={$t('continue')}
|
||||
confirmColor="green"
|
||||
onConfirm={handleRestoreUser}
|
||||
onCancel={() => dispatch('cancel')}
|
||||
{onCancel}
|
||||
>
|
||||
<svelte:fragment slot="prompt">
|
||||
<p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue