external url direct handler

This commit is contained in:
Siddharth
2025-11-09 17:36:32 -07:00
parent ddd0adcea2
commit ee8b64e590
7 changed files with 40 additions and 3 deletions
+1
View File
@@ -36,6 +36,7 @@ interface Window {
getRecordedVideoPath: () => Promise<{ success: boolean; path?: string; message?: string }>
setRecordingState: (recording: boolean) => Promise<void>
onStopRecordingFromTray: (callback: () => void) => () => void
openExternalUrl: (url: string) => Promise<{ success: boolean; error?: string }>
}
}
+11 -1
View File
@@ -1,4 +1,4 @@
import { ipcMain, desktopCapturer, BrowserWindow } from 'electron'
import { ipcMain, desktopCapturer, BrowserWindow, shell } from 'electron'
import { startMouseTracking, stopMouseTracking, getTrackingData } from './mouseTracking'
import fs from 'node:fs/promises'
import path from 'node:path'
@@ -134,4 +134,14 @@ export function registerIpcHandlers(
onRecordingStateChange(recording, source.name)
}
})
ipcMain.handle('open-external-url', async (_, url: string) => {
try {
await shell.openExternal(url)
return { success: true }
} catch (error) {
console.error('Failed to open URL:', error)
return { success: false, error: String(error) }
}
})
}
+3
View File
@@ -38,5 +38,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
const listener = () => callback()
ipcRenderer.on('stop-recording-from-tray', listener)
return () => ipcRenderer.removeListener('stop-recording-from-tray', listener)
},
openExternalUrl: (url: string) => {
return ipcRenderer.invoke('open-external-url', url)
}
})