import { useState, useRef, useEffect } from "react"; import EmojiPicker, { Theme as EmojiTheme } from "emoji-picker-react"; import styles from "./settings.module.scss"; import ResetIcon from "../icons/reload.svg"; import CloseIcon from "../icons/close.svg"; import ClearIcon from "../icons/clear.svg"; import { List, ListItem, Popover } from "./ui-lib"; import { IconButton } from "./button"; import { SubmitKey, useChatStore, Theme } from "../store"; import { Avatar } from "./home"; import Locale, { changeLang, getLang } from '../locales' export function Settings(props: { closeSettings: () => void }) { const [showEmojiPicker, setShowEmojiPicker] = useState(false); const [config, updateConfig, resetConfig, clearAllData] = useChatStore((state) => [ state.config, state.updateConfig, state.resetConfig, state.clearAllData, ]); return ( <>
{Locale.Settings.Title}
{Locale.Settings.SubTitle}
} onClick={clearAllData} bordered title={Locale.Settings.Actions.ClearAll} />
} onClick={resetConfig} bordered title={Locale.Settings.Actions.ResetAll} />
} onClick={props.closeSettings} bordered title={Locale.Settings.Actions.Close} />
{Locale.Settings.Avatar}
setShowEmojiPicker(false)} content={ { updateConfig((config) => (config.avatar = e.unified)); setShowEmojiPicker(false); }} /> } open={showEmojiPicker} >
setShowEmojiPicker(true)} >
{Locale.Settings.SendKey}
{Locale.Settings.Theme}
{Locale.Settings.TightBorder}
updateConfig( (config) => (config.tightBorder = e.currentTarget.checked) ) } >
{Locale.Settings.Lang.Name}
{Locale.Settings.HistoryCount}
updateConfig( (config) => (config.historyMessageCount = e.target.valueAsNumber) ) } >
{Locale.Settings.CompressThreshold}
updateConfig( (config) => (config.compressMessageLengthThreshold = e.currentTarget.valueAsNumber) ) } >
); }