Fix persisting cloud sync setting

This commit is contained in:
Mattias Granlund 2024-01-02 13:09:59 +01:00
parent ef0f69eb55
commit 9a3d458e30

View File

@ -29,12 +29,8 @@
dispatch('updated', { ...project, api: { ...cloudProject, sync: project.api.sync } });
});
const onSyncChange = async (event: Event) => {
const onSyncChange = async (event: CustomEvent<boolean>) => {
if (!user) return;
const target = event.target as HTMLInputElement;
const sync = target.checked;
try {
const cloudProject =
project.api ??
@ -43,7 +39,7 @@
description: project.description,
uid: project.id
}));
dispatch('updated', { ...project, api: { ...cloudProject, sync } });
dispatch('updated', { ...project, api: { ...cloudProject, sync: event.detail } });
} catch (error) {
console.error(`Failed to update project sync status: ${error}`);
toasts.error('Failed to update project sync status');
@ -63,8 +59,7 @@
class="flex flex-row items-center justify-between rounded-lg border border-light-400 p-2 dark:border-dark-500"
>
<div class="flex flex-row space-x-3">
<div class="flex flex-row">
<form class="flex items-center gap-1">
<div class="flex flex-row items-center gap-x-1">
<Checkbox
name="sync"
disabled={user === undefined}
@ -74,7 +69,6 @@
}}
/>
<label class="ml-2" for="sync">Enable branch and commit message generation.</label>
</form>
</div>
</div>
</div>
@ -86,8 +80,7 @@
class="flex flex-row items-center justify-between rounded-lg border border-light-400 p-2 dark:border-dark-500"
>
<div class="flex flex-row space-x-3">
<div class="flex flex-row">
<form class="flex items-center gap-1">
<div class="flex flex-row items-center gap-1">
<Checkbox
name="sync"
disabled={user === undefined}
@ -97,7 +90,6 @@
<label class="ml-2" for="sync">
Sync my history, repository and branch data for backup, sharing and team features.
</label>
</form>
</div>
</div>
</div>