Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
Fix repeated reboots when useWindowFrame switch (#457)
Browse files Browse the repository at this point in the history
- add debounce / statelock(isRelaunching) to avoid multiple restarts due to rapid consecutive clicks.
  • Loading branch information
MingLLuo authored Jan 17, 2025
1 parent df7066a commit 749ac64
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/renderer/src/components/settings/general-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
writeTheme
} from '@renderer/utils/ipc'
import { useAppConfig } from '@renderer/hooks/use-app-config'
import debounce from '@renderer/utils/debounce'
import { platform } from '@renderer/utils/init'
import { useTheme } from 'next-themes'
import { IoIosHelpCircle, IoMdCloudDownload } from 'react-icons/io'
Expand All @@ -35,6 +36,7 @@ const GeneralConfig: React.FC = () => {
const [customThemes, setCustomThemes] = useState<{ key: string; label: string }[]>()
const [openCSSEditor, setOpenCSSEditor] = useState(false)
const [fetching, setFetching] = useState(false)
const [isRelaunching, setIsRelaunching] = useState(false)
const { setTheme } = useTheme()
const {
silentStart = false,
Expand Down Expand Up @@ -270,10 +272,18 @@ const GeneralConfig: React.FC = () => {
<Switch
size="sm"
isSelected={useWindowFrame}
onValueChange={async (v) => {
await patchAppConfig({ useWindowFrame: v })
await relaunchApp()
}}
isDisabled={isRelaunching}
onValueChange={debounce(async (v) => {
if (isRelaunching) return
setIsRelaunching(true)
try {
await patchAppConfig({ useWindowFrame: v })
await relaunchApp()
} catch (e) {
alert(e)
setIsRelaunching(false)
}
}, 1000)}
/>
</SettingItem>
<SettingItem title="背景色" divider>
Expand Down

0 comments on commit 749ac64

Please sign in to comment.