diff --git a/src/components/Dashboard/context/AppUpdateContext.jsx b/src/components/Dashboard/context/AppUpdateContext.jsx index 1203906..7589525 100644 --- a/src/components/Dashboard/context/AppUpdateContext.jsx +++ b/src/components/Dashboard/context/AppUpdateContext.jsx @@ -130,7 +130,8 @@ export const AppUpdateProvider = ({ children }) => { setAppSettings, getAppEngine, startAppUpdate, - onAppUpdateProgress + onAppUpdateProgress, + onCheckForUpdatesRequest } = useContext(ElectronContext) const [checking, setChecking] = useState(false) const [noUpdateOpen, setNoUpdateOpen] = useState(false) @@ -300,6 +301,14 @@ export const AppUpdateProvider = ({ children }) => { }) }, [isElectron, onAppUpdateProgress]) + useEffect(() => { + if (!isElectron || !onCheckForUpdatesRequest) return undefined + + return onCheckForUpdatesRequest(() => { + void checkForUpdates() + }) + }, [isElectron, onCheckForUpdatesRequest, checkForUpdates]) + const dismissUpdatePrompt = () => { if (availableUpdate) { saveDismissedUpdate(availableUpdate) diff --git a/src/components/Dashboard/context/ElectronContext.jsx b/src/components/Dashboard/context/ElectronContext.jsx index 28b0a78..0e3b6eb 100644 --- a/src/components/Dashboard/context/ElectronContext.jsx +++ b/src/components/Dashboard/context/ElectronContext.jsx @@ -321,6 +321,31 @@ const ElectronProvider = ({ children }) => { [electronAvailable, useElectrobun] ) + const onCheckForUpdatesRequest = useCallback( + (handler) => { + if (!electronAvailable || typeof handler !== 'function') { + return () => {} + } + + if (useElectrobun) { + return desktopBridge.onMessage('checkForUpdates', handler) + } + + if (!ipcRenderer) return () => {} + + const checkHandler = () => { + handler() + } + + ipcRenderer.on('check-for-updates', checkHandler) + + return () => { + ipcRenderer.removeListener('check-for-updates', checkHandler) + } + }, + [electronAvailable, useElectrobun] + ) + const getToken = async () => { const session = await getAuthSession() return session?.token || null @@ -395,6 +420,7 @@ const ElectronProvider = ({ children }) => { setAppSettings, startAppUpdate, onAppUpdateProgress, + onCheckForUpdatesRequest, getToken, setToken, resizeSpotlightWindow, diff --git a/src/desktop/menu.js b/src/desktop/menu.js index 4589185..ef02e6c 100644 --- a/src/desktop/menu.js +++ b/src/desktop/menu.js @@ -13,6 +13,11 @@ function buildMacAppMenu() { action: `${SIDEBAR_MENU_ACTION_PREFIX}/dashboard/management/about`, }, { type: "separator" }, + { + label: "Check For Updates...", + action: "check-for-updates", + }, + { type: "separator" }, { role: "hide" }, { role: "hideOthers" }, { role: "showAll" }, @@ -143,6 +148,7 @@ export function setSidebarViewMenu(sections) { export function setupApplicationMenuEvents({ onNavigate, onToggleDevTools, + onCheckForUpdates, }) { navigateHandler = onNavigate; @@ -155,6 +161,11 @@ export function setupApplicationMenuEvents({ return; } + if (action === "check-for-updates") { + onCheckForUpdates?.(); + return; + } + if (action.startsWith(SIDEBAR_MENU_ACTION_PREFIX)) { const path = action.slice(SIDEBAR_MENU_ACTION_PREFIX.length); navigateHandler?.(path || "/"); diff --git a/src/desktop/window.js b/src/desktop/window.js index cd05d52..fb46118 100644 --- a/src/desktop/window.js +++ b/src/desktop/window.js @@ -266,6 +266,9 @@ export async function createMainWindow(rpc) { onNavigate: sendNavigateToRenderer, onToggleDevTools: () => { mainWindow?.webview?.toggleDevTools?.() + }, + onCheckForUpdates: () => { + sendToRenderer('checkForUpdates') } })