Skip to content

Commit 9014399

Browse files
committed
fix(desktop): hide unsupported microphone settings action
1 parent c941a13 commit 9014399

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

apps/desktop/src/preload/index.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,21 @@ describe('desktop preload bridge', () => {
4545
['desktop:settings:set-browser-search-suggestions', false],
4646
])
4747
})
48+
49+
it('exposes native microphone settings only on supported platforms', async () => {
50+
const exposed = exposeInMainWorld.mock.calls.find(([name]) => name === 'simDesktop')?.[1] as
51+
| SimDesktopApi
52+
| undefined
53+
if (!exposed) throw new Error('Expected the desktop preload API to be exposed')
54+
55+
const isSupportedPlatform = process.platform === 'darwin' || process.platform === 'win32'
56+
expect(typeof exposed.openMicrophoneSettings).toBe(
57+
isSupportedPlatform ? 'function' : 'undefined'
58+
)
59+
60+
if (isSupportedPlatform) {
61+
await exposed.openMicrophoneSettings?.()
62+
expect(invoke).toHaveBeenLastCalledWith('desktop:open-microphone-settings')
63+
}
64+
})
4865
})

apps/desktop/src/preload/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ function shellVersion(): string {
114114
const api: SimDesktopApi = {
115115
version: shellVersion(),
116116
openExternal: (url: string): Promise<boolean> => ipcRenderer.invoke('desktop:open-external', url),
117-
openMicrophoneSettings: (): Promise<boolean> =>
118-
ipcRenderer.invoke('desktop:open-microphone-settings'),
117+
...(process.platform === 'darwin' || process.platform === 'win32'
118+
? {
119+
openMicrophoneSettings: (): Promise<boolean> =>
120+
ipcRenderer.invoke('desktop:open-microphone-settings'),
121+
}
122+
: {}),
119123
beginOAuthConnect: (providerId: string, scope?: DesktopOAuthConnectScope): Promise<boolean> =>
120124
ipcRenderer.invoke('desktop:oauth-connect', providerId, scope),
121125
onOAuthConnectComplete: (callback: (result: DesktopOAuthConnectResult) => void): (() => void) => {

0 commit comments

Comments
 (0)