提交 6808ed5b 编写于 作者: J Joao Moreno

ipc: drop update related IPC messages

上级 b158869d
......@@ -22,7 +22,6 @@ import { ipcMain as ipc, app, screen, BrowserWindow, dialog } from 'electron';
import { IPathWithLineAndColumn, parseLineAndColumnAware } from 'vs/code/electron-main/paths';
import { ILifecycleService } from 'vs/code/electron-main/lifecycle';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IUpdateService } from 'vs/platform/update/common/update';
import { ILogService } from 'vs/code/electron-main/log';
import { IWindowEventService } from 'vs/code/common/windows';
import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -152,7 +151,6 @@ export class WindowsManager implements IWindowsMainService, IWindowEventService
@IStorageService private storageService: IStorageService,
@IEnvironmentService private environmentService: IEnvironmentService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IUpdateService private updateService: IUpdateService,
@IConfigurationService private configurationService: IConfigurationService
) { }
......@@ -249,35 +247,6 @@ export class WindowsManager implements IWindowsMainService, IWindowEventService
}
});
this.updateService.onUpdateReady(update => {
this.sendToFocused('vscode:telemetry', { eventName: 'update:downloaded', data: { version: update.version } });
this.sendToAll('vscode:update-downloaded', JSON.stringify({
releaseNotes: update.releaseNotes,
version: update.version,
date: update.date
}));
});
ipc.on('vscode:update-apply', () => {
this.logService.log('IPC#vscode:update-apply');
this.updateService.quitAndInstall();
});
this.updateService.onUpdateNotAvailable(explicit => {
this.sendToFocused('vscode:telemetry', { eventName: 'update:notAvailable', data: { explicit } });
if (explicit) {
this.sendToFocused('vscode:update-not-available', '');
}
});
this.updateService.onUpdateAvailable(({ url, version }) => {
if (url) {
this.sendToFocused('vscode:update-available', url, version);
}
});
this.lifecycleService.onBeforeQuit(() => {
// 0-1 window open: Do not keep the list but just rely on the active window to be stored
......
......@@ -23,6 +23,16 @@ import product from 'vs/platform/product';
import { TPromise } from 'vs/base/common/winjs.base';
import { IUpdateService, State, IAutoUpdater, IUpdate, IRawUpdate } from 'vs/platform/update/common/update';
// TODO@Joao: add telemetry
//
// this.updateService.onUpdateReady(update => {
// this.sendToFocused('vscode:telemetry', { eventName: 'update:downloaded', data: { version: update.version } });
// });
// this.updateService.onUpdateNotAvailable(explicit => {
// this.sendToFocused('vscode:telemetry', { eventName: 'update:notAvailable', data: { explicit } });
// });
export class UpdateService implements IUpdateService {
_serviceBrand: any;
......@@ -233,4 +243,4 @@ export class UpdateService implements IUpdateService {
this.raw.quitAndInstall();
});
}
}
}
\ No newline at end of file
......@@ -9,7 +9,6 @@ import nls = require('vs/nls');
import severity from 'vs/base/common/severity';
import { TPromise } from 'vs/base/common/winjs.base';
import { Action } from 'vs/base/common/actions';
import { ipcRenderer as ipc } from 'electron';
import { IMessageService, CloseAction, Severity } from 'vs/platform/message/common/message';
import pkg from 'vs/platform/package';
import product from 'vs/platform/product';
......@@ -25,21 +24,18 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IUpdateService } from 'vs/platform/update/common/update';
import * as semver from 'semver';
interface IUpdate {
releaseNotes: string;
version: string;
date: string;
}
class ApplyUpdateAction extends Action {
constructor( @IUpdateService private updateService: IUpdateService) {
super('update.applyUpdate', nls.localize('updateNow', "Update Now"), null, true);
}
const ApplyUpdateAction = new Action(
'update.applyUpdate',
nls.localize('updateNow', "Update Now"),
null,
true,
() => { ipc.send('vscode:update-apply'); return TPromise.as(true); }
);
run(): TPromise<void> {
return this.updateService.quitAndInstall();
}
}
const NotNowAction = new Action(
'update.later',
......@@ -196,6 +192,7 @@ export class UpdateContribution implements IWorkbenchContribution {
@IStorageService storageService: IStorageService,
@IInstantiationService instantiationService: IInstantiationService,
@IMessageService messageService: IMessageService,
@IUpdateService updateService: IUpdateService,
@IWorkbenchEditorService editorService: IWorkbenchEditorService
) {
const lastVersion = storageService.get(UpdateContribution.KEY, StorageScope.GLOBAL, '');
......@@ -250,26 +247,34 @@ export class UpdateContribution implements IWorkbenchContribution {
storageService.store(UpdateContribution.KEY, pkg.version, StorageScope.GLOBAL);
ipc.on('vscode:update-downloaded', (event, data: string) => {
const update = JSON.parse(data) as IUpdate;
updateService.onUpdateReady(update => {
const applyUpdateAction = instantiationService.createInstance(ApplyUpdateAction);
const releaseNotesAction = instantiationService.createInstance(ShowReleaseNotesAction, false, update.version);
messageService.show(severity.Info, {
message: nls.localize('updateAvailable', "{0} will be updated after it restarts.", product.nameLong),
actions: [ApplyUpdateAction, NotNowAction, releaseNotesAction]
actions: [applyUpdateAction, NotNowAction, releaseNotesAction]
});
});
ipc.on('vscode:update-available', (event, url: string, version: string) => {
const releaseNotesAction = instantiationService.createInstance(ShowReleaseNotesAction, false, version);
updateService.onUpdateAvailable(update => {
if (!update.url) {
return;
}
const releaseNotesAction = instantiationService.createInstance(ShowReleaseNotesAction, false, update.version);
messageService.show(severity.Info, {
message: nls.localize('thereIsUpdateAvailable', "There is an available update."),
actions: [DownloadAction(url), NotNowAction, releaseNotesAction]
actions: [DownloadAction(update.url), NotNowAction, releaseNotesAction]
});
});
ipc.on('vscode:update-not-available', () => {
updateService.onUpdateNotAvailable(explicit => {
if (!explicit) {
return;
}
messageService.show(severity.Info, nls.localize('noUpdatesAvailable', "There are no updates currently available."));
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册