chore: refactor

This commit is contained in:
naiba
2024-12-15 20:26:35 +08:00
parent 3ec7e7a784
commit 855b5d4cc8
3 changed files with 29 additions and 55 deletions

View File

@@ -22,15 +22,15 @@ enum OSTypes {
export const InstallCommandsMenu = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
const [copy, setCopy] = useState(false)
const settings = useSettings()
const {data: settings} = useSettings()
const { t } = useTranslation()
const switchState = async (type: number) => {
if (!copy) {
try {
setCopy(true)
if (!settings.data) throw new Error("Settings is not found.")
await copyToClipboard(generateCommand(type, settings.data) || "")
if (!settings) throw new Error("Settings is not found.")
await copyToClipboard(generateCommand(type, settings) || "")
} catch (e: Error | any) {
console.error(e)
toast(t("Error"), {