Add button in settings menu to manually check for updates (#5607)

* Expose an electron handler for checking for updates

* Add "Check for updates" button to settings
This commit is contained in:
Frank Noirot
2025-03-04 12:41:35 -05:00
committed by GitHub
parent df278c7e6a
commit 8ba1a5cd4d
4 changed files with 27 additions and 7 deletions

1
interface.d.ts vendored
View File

@ -88,6 +88,7 @@ export interface IElectronAPI {
) => Electron.IpcRenderer ) => Electron.IpcRenderer
onUpdateError: (callback: (value: { error: Error }) => void) => Electron onUpdateError: (callback: (value: { error: Error }) => void) => Electron
appRestart: () => void appRestart: () => void
appCheckForUpdates: () => Promise<unknown>
getArgvParsed: () => any getArgvParsed: () => any
getAppTestProperty: (propertyName: string) => any getAppTestProperty: (propertyName: string) => any
} }

View File

@ -252,15 +252,29 @@ export const AllSettingsFields = forwardRef(
{/* This uses a Vite plugin, set in vite.config.ts {/* This uses a Vite plugin, set in vite.config.ts
to inject the version from package.json */} to inject the version from package.json */}
App version {APP_VERSION}.{' '} App version {APP_VERSION}.{' '}
<a </p>
onClick={openExternalBrowserIfDesktop(getReleaseUrl())} <div className="flex gap-2 flex-wrap my-4">
href={getReleaseUrl()} <ActionButton
target="_blank" Element="externalLink"
rel="noopener noreferrer" to={getReleaseUrl()}
iconStart={{ icon: 'file', className: 'p-1' }}
> >
View release on GitHub View release on GitHub
</a> </ActionButton>
</p> <ActionButton
Element="button"
onClick={() => {
window.electron.appCheckForUpdates().catch(reportRejection)
}}
iconStart={{
icon: 'refresh',
size: 'sm',
className: 'p-1',
}}
>
Check for updates
</ActionButton>
</div>
<p className="max-w-2xl mt-6"> <p className="max-w-2xl mt-6">
Don't see the feature you want? Check to see if it's on{' '} Don't see the feature you want? Check to see if it's on{' '}
<a <a

View File

@ -430,6 +430,9 @@ app.on('ready', () => {
ipcMain.handle('app.restart', () => { ipcMain.handle('app.restart', () => {
autoUpdater.quitAndInstall() autoUpdater.quitAndInstall()
}) })
ipcMain.handle('app.checkForUpdates', () => {
return autoUpdater.checkForUpdates()
})
}) })
const getProjectPathAtStartup = async ( const getProjectPathAtStartup = async (

View File

@ -38,6 +38,7 @@ const onUpdateDownloadStart = (
const onUpdateError = (callback: (value: Error) => void) => const onUpdateError = (callback: (value: Error) => void) =>
ipcRenderer.on('update-error', (_event: any, value) => callback(value)) ipcRenderer.on('update-error', (_event: any, value) => callback(value))
const appRestart = () => ipcRenderer.invoke('app.restart') const appRestart = () => ipcRenderer.invoke('app.restart')
const appCheckForUpdates = () => ipcRenderer.invoke('app.checkForUpdates')
const getAppTestProperty = (propertyName: string) => const getAppTestProperty = (propertyName: string) =>
ipcRenderer.invoke('app.testProperty', propertyName) ipcRenderer.invoke('app.testProperty', propertyName)
@ -207,6 +208,7 @@ contextBridge.exposeInMainWorld('electron', {
onUpdateDownloaded, onUpdateDownloaded,
onUpdateError, onUpdateError,
appRestart, appRestart,
appCheckForUpdates,
getArgvParsed, getArgvParsed,
resizeWindow, resizeWindow,
}) })