fix Cancel

This commit is contained in:
proddy
2023-06-24 16:51:04 +02:00
parent 89f14f1dba
commit d6c5c87412
2 changed files with 19 additions and 5 deletions

View File

@@ -34,7 +34,8 @@ const SettingsEntities: FC = () => {
send: fetchEntities,
error
} = useRequest(EMSESP.readEntities, {
initialData: []
initialData: [],
force: true
});
const { send: writeEntities } = useRequest((data) => EMSESP.writeEntities(data), { immediate: false });
@@ -146,6 +147,12 @@ const SettingsEntities: FC = () => {
setDialogOpen(false);
};
const onDialogCancel = async () => {
await fetchEntities().then(() => {
setNumChanges(0);
});
};
const onDialogSave = (updatedItem: EntityItem) => {
setDialogOpen(false);
@@ -246,7 +253,7 @@ const SettingsEntities: FC = () => {
<Box flexGrow={1}>
{numChanges > 0 && (
<ButtonRow>
<Button startIcon={<CancelIcon />} variant="outlined" onClick={fetchEntities} color="secondary">
<Button startIcon={<CancelIcon />} variant="outlined" onClick={onDialogCancel} color="secondary">
{LL.CANCEL()}
</Button>
<Button

View File

@@ -36,7 +36,8 @@ const SettingsScheduler: FC = () => {
send: fetchSchedule,
error
} = useRequest(EMSESP.readSchedule, {
initialData: []
initialData: [],
force: true
});
const { send: writeSchedule } = useRequest((data) => EMSESP.writeSchedule(data), { immediate: false });
@@ -144,6 +145,12 @@ const SettingsScheduler: FC = () => {
setDialogOpen(false);
};
const onDialogCancel = async () => {
await fetchSchedule().then(() => {
setNumChanges(0);
});
};
const onDialogSave = (updatedItem: ScheduleItem) => {
setDialogOpen(false);
@@ -252,7 +259,7 @@ const SettingsScheduler: FC = () => {
onClose={onDialogClose}
onSave={onDialogSave}
selectedItem={selectedScheduleItem}
validator={schedulerItemValidation()}
validator={schedulerItemValidation(schedule, selectedScheduleItem)}
dow={dow}
/>
)}
@@ -261,7 +268,7 @@ const SettingsScheduler: FC = () => {
<Box flexGrow={1}>
{numChanges !== 0 && (
<ButtonRow>
<Button startIcon={<CancelIcon />} variant="outlined" onClick={fetchSchedule} color="secondary">
<Button startIcon={<CancelIcon />} variant="outlined" onClick={onDialogCancel} color="secondary">
{LL.CANCEL()}
</Button>
<Button