Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d2e43fa

Browse files
author
Alberto Iannaccone
committed
fix IDE updater commands
1 parent a5a6a0b commit d2e43fa

File tree

4 files changed

+45
-52
lines changed

4 files changed

+45
-52
lines changed

‎arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ import { ArduinoPreferences } from './arduino-preferences';
6868
import { SketchesServiceClientImpl } from '../common/protocol/sketches-service-client-impl';
6969
import { SaveAsSketch } from './contributions/save-as-sketch';
7070
import { SketchbookWidgetContribution } from './widgets/sketchbook/sketchbook-widget-contribution';
71-
import { IDEUpdaterCommands } from './ide-updater/ide-updater-commands';
7271
import { IDEUpdaterDialog } from './dialogs/ide-updater/ide-updater-dialog';
7372
import { IDEUpdater } from '../common/protocol/ide-updater';
7473

@@ -160,8 +159,8 @@ export class ArduinoFrontendContribution
160159
@inject(LocalStorageService)
161160
protected readonly localStorageService: LocalStorageService;
162161

163-
@inject(IDEUpdaterCommands)
164-
protected readonly updater: IDEUpdaterCommands;
162+
@inject(IDEUpdater)
163+
protected readonly updater: IDEUpdater;
165164

166165
@inject(IDEUpdaterDialog)
167166
protected readonly updaterDialog: IDEUpdaterDialog;
@@ -283,14 +282,21 @@ export class ArduinoFrontendContribution
283282
this.arduinoPreferences.get('arduino.ide.updateChannel'),
284283
this.arduinoPreferences.get('arduino.ide.updateBaseUrl')
285284
);
286-
this.updater.checkForUpdates(true).then(async (updateInfo) => {
287-
if (!updateInfo) return;
288-
const versionToSkip = await this.localStorageService.getData<string>(
289-
SKIP_IDE_VERSION
290-
);
291-
if (versionToSkip === updateInfo.version) return;
292-
this.updaterDialog.open(updateInfo);
293-
});
285+
this.updater
286+
.checkForUpdates(true)
287+
.then(async (updateInfo) => {
288+
if (!updateInfo) return;
289+
const versionToSkip = await this.localStorageService.getData<string>(
290+
SKIP_IDE_VERSION
291+
);
292+
if (versionToSkip === updateInfo.version) return;
293+
this.updaterDialog.open(updateInfo);
294+
})
295+
.catch((e) => {
296+
this.messageService.error(
297+
`Error while checking for Arduino IDE updates. ${e}`
298+
);
299+
});
294300

295301
const start = async ({ selectedBoard }: BoardsConfig.Config) => {
296302
if (selectedBoard) {

‎arduino-ide-extension/src/browser/contributions/help.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
KeybindingRegistry,
1414
} from './contribution';
1515
import { nls } from '@theia/core/lib/common';
16+
import { IDEUpdaterCommands } from '../ide-updater/ide-updater-commands';
1617

1718
@injectable()
1819
export class Help extends Contribution {
@@ -115,6 +116,10 @@ export class Help extends Contribution {
115116
commandId: Help.Commands.VISIT_ARDUINO.id,
116117
order: '6',
117118
});
119+
registry.registerMenuAction(ArduinoMenus.HELP__FIND_GROUP, {
120+
commandId: IDEUpdaterCommands.CHECK_FOR_UPDATES.id,
121+
order: '7',
122+
});
118123
}
119124

120125
registerKeybindings(registry: KeybindingRegistry): void {

‎arduino-ide-extension/src/browser/dialogs/ide-updater/ide-updater-dialog.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import { Message } from '@phosphor/messaging';
77
import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
88
import { nls } from '@theia/core';
99
import { IDEUpdaterComponent } from './ide-updater-component';
10-
import{IDEUpdaterCommands}from'../../ide-updater/ide-updater-commands';
10+
1111
import {
12+
IDEUpdater,
1213
IDEUpdaterClient,
1314
ProgressInfo,
1415
UpdateInfo,
@@ -27,8 +28,8 @@ export class IDEUpdaterDialogWidget extends ReactWidget {
2728
downloadStarted: boolean;
2829
onClose: () => void;
2930

30-
@inject(IDEUpdaterCommands)
31-
protected readonly updater: IDEUpdaterCommands;
31+
@inject(IDEUpdater)
32+
protected readonly updater: IDEUpdater;
3233

3334
@inject(IDEUpdaterClient)
3435
protected readonly updaterClient: IDEUpdaterClient;

‎arduino-ide-extension/src/browser/ide-updater/ide-updater-commands.ts‎

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,41 @@ import {
66
} from '@theia/core';
77
import { injectable, inject } from 'inversify';
88
import { IDEUpdater, UpdateInfo } from '../../common/protocol/ide-updater';
9+
import { IDEUpdaterDialog } from '../dialogs/ide-updater/ide-updater-dialog';
910

1011
@injectable()
1112
export class IDEUpdaterCommands implements CommandContribution {
1213
constructor(
1314
@inject(IDEUpdater)
1415
private readonly updater: IDEUpdater,
1516
@inject(MessageService)
16-
protected readonly messageService: MessageService
17+
protected readonly messageService: MessageService,
18+
@inject(IDEUpdaterDialog)
19+
protected readonly updaterDialog: IDEUpdaterDialog
1720
) {}
1821

1922
registerCommands(registry: CommandRegistry): void {
2023
registry.registerCommand(IDEUpdaterCommands.CHECK_FOR_UPDATES, {
2124
execute: this.checkForUpdates.bind(this),
2225
});
23-
registry.registerCommand(IDEUpdaterCommands.DOWNLOAD_UPDATE, {
24-
execute: this.downloadUpdate.bind(this),
25-
});
26-
registry.registerCommand(IDEUpdaterCommands.STOP_DOWNLOAD, {
27-
execute: this.stopDownload.bind(this),
28-
});
29-
registry.registerCommand(IDEUpdaterCommands.INSTALL_UPDATE, {
30-
execute: this.quitAndInstall.bind(this),
31-
});
3226
}
3327

3428
async checkForUpdates(initialCheck?: boolean): Promise<UpdateInfo | void> {
35-
return await this.updater.checkForUpdates(initialCheck);
36-
}
37-
38-
async downloadUpdate(): Promise<void> {
39-
await this.updater.downloadUpdate();
40-
}
41-
42-
async stopDownload(): Promise<void> {
43-
await this.updater.stopDownload();
44-
}
45-
46-
quitAndInstall(): void {
47-
this.updater.quitAndInstall();
29+
try {
30+
const updateInfo = await this.updater.checkForUpdates(initialCheck);
31+
if (!!updateInfo) {
32+
this.updaterDialog.open(updateInfo);
33+
} else {
34+
this.messageService.info(
35+
`There are no recent updates available the Arduino IDE`
36+
);
37+
}
38+
return updateInfo;
39+
} catch (e) {
40+
this.messageService.error(
41+
`Error while checking for Arduino IDE updates. ${e}`
42+
);
43+
}
4844
}
4945
}
5046
export namespace IDEUpdaterCommands {
@@ -53,19 +49,4 @@ export namespace IDEUpdaterCommands {
5349
category: 'Arduino',
5450
label: 'Check for Arduino IDE updates',
5551
};
56-
export const DOWNLOAD_UPDATE: Command = {
57-
id: 'arduino-ide-download-update',
58-
category: 'Arduino',
59-
label: 'Download Arduino IDE updates',
60-
};
61-
export const STOP_DOWNLOAD: Command = {
62-
id: 'arduino-ide-stop-download',
63-
category: 'Arduino',
64-
label: 'Stop download of Arduino IDE updates',
65-
};
66-
export const INSTALL_UPDATE: Command = {
67-
id: 'arduino-ide-install-update',
68-
category: 'Arduino',
69-
label: 'Install Arduino IDE updates',
70-
};
7152
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /