()
| 297 | } |
| 298 | |
| 299 | export async function downloadAppUpdate(): Promise<AppUpdateState> { |
| 300 | if (!updater || updateState.phase !== 'available') return getAppUpdateState() |
| 301 | |
| 302 | setUpdateState( |
| 303 | nextStateFromInfo( |
| 304 | 'downloading', |
| 305 | lastInfo, |
| 306 | `Downloading ZenNotes ${updateState.availableVersion ?? ''}…`, |
| 307 | { |
| 308 | progressPercent: 0, |
| 309 | transferredBytes: 0, |
| 310 | totalBytes: null, |
| 311 | bytesPerSecond: null |
| 312 | } |
| 313 | ) |
| 314 | ) |
| 315 | |
| 316 | try { |
| 317 | await updater.downloadUpdate() |
| 318 | } catch (error) { |
| 319 | setUpdateState( |
| 320 | nextStateFromInfo('error', lastInfo, humanizeUpdateError(error)) |
| 321 | ) |
| 322 | } |
| 323 | |
| 324 | return getAppUpdateState() |
| 325 | } |
| 326 | |
| 327 | export function installAppUpdate(): void { |
| 328 | if (!updater || updateState.phase !== 'downloaded') return |
no test coverage detected