mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-16 02:06:21 +01:00
Made settings auto save upon closing the drawer
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { Drawer, ScrollArea, Tabs, Title } from '@mantine/core';
|
import { Drawer, ScrollArea, Tabs, Title } from '@mantine/core';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
|
import { useConfigContext } from '../../config/provider';
|
||||||
|
import { useConfigStore } from '../../config/store';
|
||||||
|
|
||||||
import CommonSettings from './Common/CommonSettings';
|
import CommonSettings from './Common/CommonSettings';
|
||||||
import CustomizationSettings from './Customization/CustomizationSettings';
|
import CustomizationSettings from './Customization/CustomizationSettings';
|
||||||
@@ -34,6 +36,8 @@ export function SettingsDrawer({
|
|||||||
newVersionAvailable,
|
newVersionAvailable,
|
||||||
}: SettingsDrawerProps & { newVersionAvailable: string }) {
|
}: SettingsDrawerProps & { newVersionAvailable: string }) {
|
||||||
const { t } = useTranslation('settings/common');
|
const { t } = useTranslation('settings/common');
|
||||||
|
const { config, name: configName } = useConfigContext();
|
||||||
|
const { updateConfig } = useConfigStore();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<Drawer
|
||||||
@@ -42,7 +46,14 @@ export function SettingsDrawer({
|
|||||||
position="right"
|
position="right"
|
||||||
title={<Title order={5}>{t('title')}</Title>}
|
title={<Title order={5}>{t('title')}</Title>}
|
||||||
opened={opened}
|
opened={opened}
|
||||||
onClose={closeDrawer}
|
onClose={() => {
|
||||||
|
closeDrawer();
|
||||||
|
if (!configName || !config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateConfig(configName, (_) => config, false, true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<SettingsMenu newVersionAvailable={newVersionAvailable} />
|
<SettingsMenu newVersionAvailable={newVersionAvailable} />
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|||||||
Reference in New Issue
Block a user