|
|
|
@ -2,13 +2,7 @@ import { useTranslation } from "react-i18next";
|
|
|
|
|
import Switch from "@mui/joy/Switch";
|
|
|
|
|
import { globalService, userService } from "../../services";
|
|
|
|
|
import { useAppSelector } from "../../store";
|
|
|
|
|
import {
|
|
|
|
|
VISIBILITY_SELECTOR_ITEMS,
|
|
|
|
|
MEMO_DISPLAY_TS_OPTION_SELECTOR_ITEMS,
|
|
|
|
|
SETTING_IS_FOLDING_ENABLED_KEY,
|
|
|
|
|
IS_FOLDING_ENABLED_DEFAULT_VALUE,
|
|
|
|
|
} from "../../helpers/consts";
|
|
|
|
|
import useLocalStorage from "../../hooks/useLocalStorage";
|
|
|
|
|
import { VISIBILITY_SELECTOR_ITEMS, MEMO_DISPLAY_TS_OPTION_SELECTOR_ITEMS } from "../../helpers/consts";
|
|
|
|
|
import Selector from "../common/Selector";
|
|
|
|
|
import "../../less/settings/preferences-section.less";
|
|
|
|
|
|
|
|
|
@ -33,7 +27,7 @@ const localeSelectorItems = [
|
|
|
|
|
|
|
|
|
|
const PreferencesSection = () => {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const { setting } = useAppSelector((state) => state.user.user as User);
|
|
|
|
|
const { setting, localSetting } = useAppSelector((state) => state.user.user as User);
|
|
|
|
|
const visibilitySelectorItems = VISIBILITY_SELECTOR_ITEMS.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
value: item.value,
|
|
|
|
@ -48,8 +42,6 @@ const PreferencesSection = () => {
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const [isFoldingEnabled, setIsFoldingEnabled] = useLocalStorage(SETTING_IS_FOLDING_ENABLED_KEY, IS_FOLDING_ENABLED_DEFAULT_VALUE);
|
|
|
|
|
|
|
|
|
|
const handleLocaleChanged = async (value: string) => {
|
|
|
|
|
await userService.upsertUserSetting("locale", value);
|
|
|
|
|
globalService.setLocale(value as Locale);
|
|
|
|
@ -64,7 +56,7 @@ const PreferencesSection = () => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleIsFoldingEnabledChanged = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
setIsFoldingEnabled(event.target.checked);
|
|
|
|
|
userService.upsertLocalSetting("isFoldingEnabled", event.target.checked);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
@ -95,7 +87,7 @@ const PreferencesSection = () => {
|
|
|
|
|
</label>
|
|
|
|
|
<label className="form-label selector">
|
|
|
|
|
<span className="normal-text">{t("setting.preference-section.enable-folding-memo")}</span>
|
|
|
|
|
<Switch className="ml-2" checked={isFoldingEnabled} onChange={handleIsFoldingEnabledChanged} />
|
|
|
|
|
<Switch className="ml-2" checked={localSetting.isFoldingEnabled} onChange={handleIsFoldingEnabledChanged} />
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|