MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / runMenuUpdateCheck

Function runMenuUpdateCheck

apps/desktop/src/main/index.ts:3279–3357  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3277}
3278
3279async function runMenuUpdateCheck(): Promise<void> {
3280 const parent = BrowserWindow.getFocusedWindow() ?? mainWindow ?? undefined
3281 const showDialog = async (
3282 options: Electron.MessageBoxOptions
3283 ): Promise<Electron.MessageBoxReturnValue> => {
3284 return parent
3285 ? await dialog.showMessageBox(parent, options)
3286 : await dialog.showMessageBox(options)
3287 }
3288 const state = await checkForAppUpdates()
3289
3290 if (state.phase === 'available') {
3291 const { response } = await showDialog({
3292 type: 'info',
3293 buttons: ['Download Update', 'Later'],
3294 defaultId: 0,
3295 cancelId: 1,
3296 title: 'ZenNotes Update Available',
3297 message: `ZenNotes ${state.availableVersion ?? ''} is available.`,
3298 detail: state.message
3299 })
3300 if (response === 0) {
3301 void downloadAppUpdate()
3302 await showDialog({
3303 type: 'info',
3304 buttons: ['OK'],
3305 defaultId: 0,
3306 title: 'Downloading Update',
3307 message: `ZenNotes ${state.availableVersion ?? ''} is downloading in the background.`,
3308 detail: 'Open Settings → About to track progress and install when the download finishes.'
3309 })
3310 }
3311 return
3312 }
3313
3314 if (state.phase === 'downloaded') {
3315 const { response } = await showDialog({
3316 type: 'info',
3317 buttons: ['Install and Relaunch', 'Later'],
3318 defaultId: 0,
3319 cancelId: 1,
3320 title: 'ZenNotes Update Ready',
3321 message: `ZenNotes ${state.availableVersion ?? ''} is ready to install.`,
3322 detail: state.message
3323 })
3324 if (response === 0) {
3325 installAppUpdate()
3326 }
3327 return
3328 }
3329
3330 if (state.phase === 'downloading' || state.phase === 'checking') {
3331 await showDialog({
3332 type: 'info',
3333 buttons: ['OK'],
3334 defaultId: 0,
3335 title: 'ZenNotes Updates',
3336 message: state.phase === 'checking' ? 'Checking for updates…' : 'Downloading update…',

Callers 2

registerIpcFunction · 0.85
installAppMenuFunction · 0.85

Calls 4

checkForAppUpdatesFunction · 0.90
downloadAppUpdateFunction · 0.90
installAppUpdateFunction · 0.90
showDialogFunction · 0.85

Tested by

no test coverage detected