Skip to content

Commit

Permalink
fix: do not show the translator window if the app runs at startup (#1599
Browse files Browse the repository at this point in the history
)
  • Loading branch information
WhiteDG committed Jun 19, 2024
1 parent 653a8e9 commit d4d7d43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/common/hooks/useMemoWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const sizeKey = '_size'
export type WindowMemoProps = {
size: boolean
position: boolean
show: boolean
}

/**
Expand Down Expand Up @@ -48,13 +49,15 @@ export const useMemoWindow = (props: WindowMemoProps) => {
} catch (e) {
console.error(e)
} finally {
await appWindow.unminimize()
await appWindow.setFocus()
await appWindow.show()
if (props.show) {
await appWindow.unminimize()
await appWindow.setFocus()
await appWindow.show()
}
}
}
initWindow()
}, [props.position, props.size])
}, [props.position, props.size, props.show])

useEffect(() => {
const appWindow = getCurrent()
Expand Down
6 changes: 3 additions & 3 deletions src/tauri/windows/TranslatorWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export function TranslatorWindow() {
}
}, [writingFlag])

useMemoWindow({ size: true, position: false })
const { settings } = useSettings()

useMemoWindow({ size: true, position: false, show: !settings.runAtStartup })

useEffect(() => {
setupAnalysis()
Expand Down Expand Up @@ -104,8 +106,6 @@ export function TranslatorWindow() {
}
}, [])

const { settings } = useSettings()

useEffect(() => {
if (!settings?.writingTargetLanguage) {
return
Expand Down

0 comments on commit d4d7d43

Please sign in to comment.