refactor(web): migrate away from event dispatcher (#12802)

This commit is contained in:
Jason Rasmussen 2024-09-19 18:20:09 -04:00 committed by GitHub
parent cfc575d89c
commit 94fc1f213a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 76 additions and 123 deletions

View file

@ -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>