提交 68b086c3 编写于 作者: J João Moreno

ipc: update fixes

上级 f6e89e02
......@@ -118,10 +118,6 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
}
// Register Main IPC services
const updateService = accessor.get(IUpdateService);
const updateChannel = new UpdateChannel(updateService);
mainIpcServer.registerChannel('update', updateChannel);
const launchService = instantiationService.createInstance(LaunchService);
const launchChannel = new LaunchChannel(launchService);
mainIpcServer.registerChannel('launch', launchChannel);
......@@ -134,6 +130,10 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: platfo
const electronIpcServer = new ElectronIPCServer();
// Register Electron IPC services
const updateService = accessor.get(IUpdateService);
const updateChannel = new UpdateChannel(updateService);
electronIpcServer.registerChannel('update', updateChannel);
const urlService = accessor.get(IURLService);
const urlChannel = instantiationService.createInstance(URLChannel, urlService);
electronIpcServer.registerChannel('url', urlChannel);
......
......@@ -9,7 +9,7 @@ import * as fs from 'original-fs';
import * as path from 'path';
import * as electron from 'electron';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import Event, { Emitter, once } from 'vs/base/common/event';
import Event, { Emitter, once, filterEvent } from 'vs/base/common/event';
import { always, Throttler } from 'vs/base/common/async';
import { memoize } from 'vs/base/common/decorators';
import { fromEventEmitter } from 'vs/base/node/event';
......@@ -72,7 +72,7 @@ export class UpdateService implements IUpdateService {
@memoize
private get onRawUpdateAvailable(): Event<{ url: string; version: string; }> {
return fromEventEmitter(this.raw, 'update-available', (_, url, version) => ({ url, version }));
return filterEvent(fromEventEmitter(this.raw, 'update-available', (_, url, version) => ({ url, version })), ({ url }) => !!url);
}
@memoize
......@@ -148,6 +148,10 @@ export class UpdateService implements IUpdateService {
}
private _checkForUpdates(explicit: boolean): TPromise<IUpdate> {
if (this.state !== State.Idle) {
return TPromise.as(null);
}
this._onCheckForUpdate.fire();
this.state = State.CheckingForUpdate;
......@@ -220,12 +224,12 @@ export class UpdateService implements IUpdateService {
quitAndInstall(): TPromise<void> {
if (!this._availableUpdate) {
return;
return TPromise.as(null);
}
if (this._availableUpdate.url) {
electron.shell.openExternal(this._availableUpdate.url);
return;
return TPromise.as(null);
}
this.lifecycleService.quit(true /* from update */).done(vetod => {
......@@ -242,5 +246,7 @@ export class UpdateService implements IUpdateService {
this.raw.quitAndInstall();
});
return TPromise.as(null);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册