Skip to content

Commit

Permalink
fix: resolve titlebar overlay and controlled component warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pompurin404 committed Feb 4, 2025
1 parent a69d24b commit 4a48445
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/main/utils/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ export function registerIpcMainHandlers(): void {
})
ipcMain.handle('setTitleBarOverlay', (_e, overlay) =>
ipcErrorWrapper(async (overlay): Promise<void> => {
mainWindow?.setTitleBarOverlay(overlay)
if (mainWindow && typeof mainWindow.setTitleBarOverlay === 'function') {
mainWindow.setTitleBarOverlay(overlay)
}
})(overlay)
)
ipcMain.handle('setAlwaysOnTop', (_e, alwaysOnTop) => {
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/src/components/base/border-swtich.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import React from 'react'
import { cn, Switch, SwitchProps } from '@heroui/react'
import './border-switch.css'

interface SiderSwitchProps extends SwitchProps {
interface BorderSwitchProps extends Omit<SwitchProps, 'isSelected'> {
isShowBorder?: boolean
isSelected?: boolean
}

const BorderSwitch: React.FC<SiderSwitchProps> = (props) => {
const { isShowBorder = false, classNames, ...switchProps } = props
const BorderSwitch: React.FC<BorderSwitchProps> = (props) => {
const { isShowBorder = false, isSelected = false, classNames, ...switchProps } = props

return (
<Switch
Expand All @@ -21,6 +22,7 @@ const BorderSwitch: React.FC<SiderSwitchProps> = (props) => {
...classNames
}}
size="sm"
isSelected={isSelected}
{...switchProps}
/>
)
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/sider/sysproxy-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const SysproxySwitcher: React.FC<Props> = (props) => {
</Button>
<BorderSwitch
isShowBorder={match && enable}
isSelected={enable}
isSelected={enable ?? false}
onValueChange={onChange}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/sider/tun-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const TunSwitcher: React.FC<Props> = (props) => {
</Button>
<BorderSwitch
isShowBorder={match && enable}
isSelected={enable}
isSelected={enable ?? false}
onValueChange={onChange}
/>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/src/utils/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ export async function webdavDelete(filename: string): Promise<void> {
}

export async function setTitleBarOverlay(overlay: TitleBarOverlayOptions): Promise<void> {
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('setTitleBarOverlay', overlay))
try {
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('setTitleBarOverlay', overlay))
} catch (error) {
console.debug('setTitleBarOverlay not supported on this platform')
}
}

export async function setAlwaysOnTop(alwaysOnTop: boolean): Promise<void> {
Expand Down

0 comments on commit 4a48445

Please sign in to comment.