mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-04 16:08:32 +00:00
fix IDE updater commands (#872)
* fix IDE updater commands * reinitialise autoupdate when preferences change * fix typo + add i18n strings
This commit is contained in:
committed by
GitHub
parent
a5a6a0b611
commit
96b5edf427
@@ -3,9 +3,11 @@ import {
|
||||
CommandContribution,
|
||||
CommandRegistry,
|
||||
MessageService,
|
||||
nls,
|
||||
} from '@theia/core';
|
||||
import { injectable, inject } from 'inversify';
|
||||
import { IDEUpdater, UpdateInfo } from '../../common/protocol/ide-updater';
|
||||
import { IDEUpdaterDialog } from '../dialogs/ide-updater/ide-updater-dialog';
|
||||
|
||||
@injectable()
|
||||
export class IDEUpdaterCommands implements CommandContribution {
|
||||
@@ -13,38 +15,40 @@ export class IDEUpdaterCommands implements CommandContribution {
|
||||
@inject(IDEUpdater)
|
||||
private readonly updater: IDEUpdater,
|
||||
@inject(MessageService)
|
||||
protected readonly messageService: MessageService
|
||||
protected readonly messageService: MessageService,
|
||||
@inject(IDEUpdaterDialog)
|
||||
protected readonly updaterDialog: IDEUpdaterDialog
|
||||
) {}
|
||||
|
||||
registerCommands(registry: CommandRegistry): void {
|
||||
registry.registerCommand(IDEUpdaterCommands.CHECK_FOR_UPDATES, {
|
||||
execute: this.checkForUpdates.bind(this),
|
||||
});
|
||||
registry.registerCommand(IDEUpdaterCommands.DOWNLOAD_UPDATE, {
|
||||
execute: this.downloadUpdate.bind(this),
|
||||
});
|
||||
registry.registerCommand(IDEUpdaterCommands.STOP_DOWNLOAD, {
|
||||
execute: this.stopDownload.bind(this),
|
||||
});
|
||||
registry.registerCommand(IDEUpdaterCommands.INSTALL_UPDATE, {
|
||||
execute: this.quitAndInstall.bind(this),
|
||||
});
|
||||
}
|
||||
|
||||
async checkForUpdates(initialCheck?: boolean): Promise<UpdateInfo | void> {
|
||||
return await this.updater.checkForUpdates(initialCheck);
|
||||
}
|
||||
|
||||
async downloadUpdate(): Promise<void> {
|
||||
await this.updater.downloadUpdate();
|
||||
}
|
||||
|
||||
async stopDownload(): Promise<void> {
|
||||
await this.updater.stopDownload();
|
||||
}
|
||||
|
||||
quitAndInstall(): void {
|
||||
this.updater.quitAndInstall();
|
||||
try {
|
||||
const updateInfo = await this.updater.checkForUpdates(initialCheck);
|
||||
if (!!updateInfo) {
|
||||
this.updaterDialog.open(updateInfo);
|
||||
} else {
|
||||
this.messageService.info(
|
||||
nls.localize(
|
||||
'arduino/ide-updater/noUpdatesAvailable',
|
||||
'There are no recent updates available for the Arduino IDE'
|
||||
)
|
||||
);
|
||||
}
|
||||
return updateInfo;
|
||||
} catch (e) {
|
||||
this.messageService.error(
|
||||
nls.localize(
|
||||
'arduino/ide-updater/errorCheckingForUpdates',
|
||||
'Error while checking for Arduino IDE updates.\n{0}',
|
||||
e.message
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
export namespace IDEUpdaterCommands {
|
||||
@@ -53,19 +57,4 @@ export namespace IDEUpdaterCommands {
|
||||
category: 'Arduino',
|
||||
label: 'Check for Arduino IDE updates',
|
||||
};
|
||||
export const DOWNLOAD_UPDATE: Command = {
|
||||
id: 'arduino-ide-download-update',
|
||||
category: 'Arduino',
|
||||
label: 'Download Arduino IDE updates',
|
||||
};
|
||||
export const STOP_DOWNLOAD: Command = {
|
||||
id: 'arduino-ide-stop-download',
|
||||
category: 'Arduino',
|
||||
label: 'Stop download of Arduino IDE updates',
|
||||
};
|
||||
export const INSTALL_UPDATE: Command = {
|
||||
id: 'arduino-ide-install-update',
|
||||
category: 'Arduino',
|
||||
label: 'Install Arduino IDE updates',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user