Skip to content

Commit 0325182

Browse files
author
Akos Kitta
committed
check for updates contrib.
Signed-off-by: Akos Kitta <[email protected]>
1 parent 6f4b6b5 commit 0325182

25 files changed

+1151
-128
lines changed

arduino-ide-extension/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@
161161
"arduino": {
162162
"cli": {
163163
"version": {
164-
"owner": "arduino",
164+
"owner": "cmaglie",
165165
"repo": "arduino-cli",
166-
"commitish": "63f1e18"
166+
"commitish": "new_grpc_field_in_platform"
167167
}
168168
},
169169
"fwuploader": {

arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ import { FirstStartupInstaller } from './contributions/first-startup-installer';
314314
import { OpenSketchFiles } from './contributions/open-sketch-files';
315315
import { InoLanguage } from './contributions/ino-language';
316316
import { SelectedBoard } from './contributions/selected-board';
317-
import { CheckForUpdates } from './contributions/check-for-updates';
317+
import { CheckForIDEUpdates } from './contributions/check-for-ide-updates';
318318
import { OpenBoardsConfig } from './contributions/open-boards-config';
319319
import { SketchFilesTracker } from './contributions/sketch-files-tracker';
320320
import { MonacoThemeServiceIsReady } from './utils/window';
@@ -331,6 +331,7 @@ import {
331331
BoardsFilterRenderer,
332332
LibraryFilterRenderer,
333333
} from './widgets/component-list/filter-renderer';
334+
import { CheckForUpdates } from './contributions/check-for-updates';
334335

335336
const registerArduinoThemes = () => {
336337
const themes: MonacoThemeJson[] = [
@@ -747,9 +748,10 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
747748
Contribution.configure(bind, OpenSketchFiles);
748749
Contribution.configure(bind, InoLanguage);
749750
Contribution.configure(bind, SelectedBoard);
750-
Contribution.configure(bind, CheckForUpdates);
751+
Contribution.configure(bind, CheckForIDEUpdates);
751752
Contribution.configure(bind, OpenBoardsConfig);
752753
Contribution.configure(bind, SketchFilesTracker);
754+
Contribution.configure(bind, CheckForUpdates);
753755

754756
// Disabled the quick-pick customization from Theia when multiple formatters are available.
755757
// Use the default VS Code behavior, and pick the first one. In the IDE2, clang-format has `exclusive` selectors.

arduino-ide-extension/src/browser/arduino-preferences.ts

+9
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ export const ArduinoConfigSchema: PreferenceSchema = {
241241
),
242242
default: false,
243243
},
244+
'arduino.checkForUpdates': {
245+
type: 'boolean',
246+
description: nls.localize(
247+
'arduino/preferences/checkForUpdate',
248+
"Configure whether you receive automatic updates for the IDE, boards, and libraries. Requires an IDE restart after change. It's true by default."
249+
),
250+
default: true,
251+
},
244252
},
245253
};
246254

@@ -270,6 +278,7 @@ export interface ArduinoConfiguration {
270278
'arduino.auth.registerUri': string;
271279
'arduino.survey.notification': boolean;
272280
'arduino.cli.daemon.debug': boolean;
281+
'arduino.checkForUpdates': boolean;
273282
}
274283

275284
export const ArduinoPreferences = Symbol('ArduinoPreferences');

arduino-ide-extension/src/browser/boards/boards-auto-installer.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Installable, ResponseServiceClient } from '../../common/protocol';
1212
import { BoardsListWidgetFrontendContribution } from './boards-widget-frontend-contribution';
1313
import { nls } from '@theia/core/lib/common';
1414
import { NotificationCenter } from '../notification-center';
15+
import { InstallManually } from '../../common/nls';
1516

1617
interface AutoInstallPromptAction {
1718
// isAcceptance, whether or not the action indicates acceptance of auto-install proposal
@@ -231,14 +232,10 @@ export class BoardsAutoInstaller implements FrontendApplicationContribution {
231232
candidate: BoardsPackage
232233
): AutoInstallPromptActions {
233234
const yes = nls.localize('vscode/extensionsUtils/yes', 'Yes');
234-
const manualInstall = nls.localize(
235-
'arduino/board/installManually',
236-
'Install Manually'
237-
);
238235

239236
const actions: AutoInstallPromptActions = [
240237
{
241-
key: manualInstall,
238+
key: InstallManually,
242239
handler: () => {
243240
this.boardsManagerFrontendContribution
244241
.openView({ reveal: true })
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { nls } from '@theia/core/lib/common/nls';
2+
import { LocalStorageService } from '@theia/core/lib/browser/storage-service';
3+
import { inject, injectable } from '@theia/core/shared/inversify';
4+
import {
5+
IDEUpdater,
6+
SKIP_IDE_VERSION,
7+
} from '../../common/protocol/ide-updater';
8+
import { IDEUpdaterDialog } from '../dialogs/ide-updater/ide-updater-dialog';
9+
import { Contribution } from './contribution';
10+
11+
@injectable()
12+
export class CheckForIDEUpdates extends Contribution {
13+
@inject(IDEUpdater)
14+
private readonly updater: IDEUpdater;
15+
16+
@inject(IDEUpdaterDialog)
17+
private readonly updaterDialog: IDEUpdaterDialog;
18+
19+
@inject(LocalStorageService)
20+
private readonly localStorage: LocalStorageService;
21+
22+
override onStart(): void {
23+
this.preferences.onPreferenceChanged(
24+
({ preferenceName, newValue, oldValue }) => {
25+
if (newValue !== oldValue) {
26+
switch (preferenceName) {
27+
case 'arduino.ide.updateChannel':
28+
case 'arduino.ide.updateBaseUrl':
29+
this.updater.init(
30+
this.preferences.get('arduino.ide.updateChannel'),
31+
this.preferences.get('arduino.ide.updateBaseUrl')
32+
);
33+
}
34+
}
35+
}
36+
);
37+
}
38+
39+
override onReady(): void {
40+
const checkForUpdates = this.preferences['arduino.checkForUpdates'];
41+
if (!checkForUpdates) {
42+
return;
43+
}
44+
this.updater
45+
.init(
46+
this.preferences.get('arduino.ide.updateChannel'),
47+
this.preferences.get('arduino.ide.updateBaseUrl')
48+
)
49+
.then(() => this.updater.checkForUpdates(true))
50+
.then(async (updateInfo) => {
51+
if (!updateInfo) return;
52+
const versionToSkip = await this.localStorage.getData<string>(
53+
SKIP_IDE_VERSION
54+
);
55+
if (versionToSkip === updateInfo.version) return;
56+
this.updaterDialog.open(updateInfo);
57+
})
58+
.catch((e) => {
59+
this.messageService.error(
60+
nls.localize(
61+
'arduino/ide-updater/errorCheckingForUpdates',
62+
'Error while checking for Arduino IDE updates.\n{0}',
63+
e.message
64+
)
65+
);
66+
});
67+
}
68+
}

0 commit comments

Comments
 (0)