-
-
Notifications
You must be signed in to change notification settings - Fork 431
/
Copy pathnew-version-notification.ts
29 lines (26 loc) · 1.21 KB
/
new-version-notification.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { injectable, inject } from 'inversify';
import { MessageService } from '@theia/core/lib/common/message-service';
import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application';
import { UpdatesRetriever } from '../updates/updates-retriever';
import { shell } from 'electron';
const GO_TO_DOWNLOAD_PAGE = 'Go to download page...';
/**
* Listens on `BoardsConfig.Config` changes, if a board is selected which does not
* have the corresponding core installed, it proposes the user to install the core.
*/
@injectable()
export class NewVersionNotification implements FrontendApplicationContribution {
@inject(UpdatesRetriever)
private readonly updatesRetriever: UpdatesRetriever;
@inject(MessageService)
protected readonly messageService: MessageService;
async onStart(): Promise<void> {
if (await this.updatesRetriever.isUpdateAvailable()) {
this.messageService.info('New Arduino IDE version available.', GO_TO_DOWNLOAD_PAGE).then(async answer => {
if (answer === GO_TO_DOWNLOAD_PAGE) {
shell.openExternal('https://www.arduino.cc/en/software#experimental-software');
}
})
}
}
}