()
| 48 | // Ручная проверка из меню. Скачивание при необходимости запустит глобальный |
| 49 | // обработчик 'update-available', здесь только диалоги. |
| 50 | export async function checkForUpdatesFromMenu() { |
| 51 | function showNoUpdatesDialog() { |
| 52 | dialog.showMessageBoxSync({ |
| 53 | message: i18n.t('messages:update.noAvailable'), |
| 54 | }) |
| 55 | } |
| 56 | |
| 57 | if (!app.isPackaged) { |
| 58 | showNoUpdatesDialog() |
| 59 | return |
| 60 | } |
| 61 | |
| 62 | try { |
| 63 | const result = await autoUpdater.checkForUpdates() |
| 64 | |
| 65 | if (!result?.isUpdateAvailable) { |
| 66 | showNoUpdatesDialog() |
| 67 | return |
| 68 | } |
| 69 | |
| 70 | const latestVersion = result.updateInfo.version |
| 71 | const isAutoUpdateEnabled = store.preferences.get('updates.autoUpdate') |
| 72 | const isSameMajor = getMajorVersion(latestVersion) === currentMajorVersion |
| 73 | |
| 74 | if (isAutoUpdateEnabled && isSameMajor) { |
| 75 | dialog.showMessageBoxSync({ |
| 76 | message: i18n.t('messages:update.downloading', { |
| 77 | version: latestVersion, |
| 78 | }), |
| 79 | }) |
| 80 | return |
| 81 | } |
| 82 | |
| 83 | const buttonId = dialog.showMessageBoxSync({ |
| 84 | message: i18n.t('messages:update.available', { |
| 85 | newVersion: latestVersion, |
| 86 | oldVersion: version, |
| 87 | }), |
| 88 | buttons: [i18n.t('button.update.0'), i18n.t('button.update.1')], |
| 89 | defaultId: 0, |
| 90 | cancelId: 1, |
| 91 | }) |
| 92 | |
| 93 | if (buttonId === 0) { |
| 94 | void shell.openExternal(`${repository}/releases`) |
| 95 | } |
| 96 | } |
| 97 | catch (error) { |
| 98 | log('Error checking for updates', error) |
| 99 | showNoUpdatesDialog() |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | export function checkForUpdates() { |
| 104 | if (!app.isPackaged) { |
no test coverage detected