Skip to content

Commit b18d495

Browse files
committed
1 parent 59c18a4 commit b18d495

8 files changed

Lines changed: 31 additions & 25 deletions

File tree

src/vs/code/electron-main/menus.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,10 @@ export class CodeMenu {
10551055
return [new MenuItem({
10561056
label: nls.localize('miCheckForUpdates', "Check for Updates..."), click: () => setTimeout(() => {
10571057
this.reportMenuActionTelemetry('CheckForUpdate');
1058-
this.updateService.checkForUpdates(true);
1058+
1059+
const focusedWindow = this.windowsMainService.getFocusedWindow();
1060+
const context = focusedWindow ? { windowId: focusedWindow.id } : null;
1061+
this.updateService.checkForUpdates(context);
10591062
}, 0)
10601063
})];
10611064

src/vs/platform/update/common/update.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export enum StateType {
5050

5151
export type Uninitialized = { type: StateType.Uninitialized };
5252
export type Idle = { type: StateType.Idle };
53-
export type CheckingForUpdates = { type: StateType.CheckingForUpdates, explicit: boolean };
53+
export type CheckingForUpdates = { type: StateType.CheckingForUpdates, context: any };
5454
export type AvailableForDownload = { type: StateType.AvailableForDownload, update: IUpdate };
5555
export type Downloading = { type: StateType.Downloading, update: IUpdate };
5656
export type Downloaded = { type: StateType.Downloaded, update: IUpdate };
@@ -62,7 +62,7 @@ export type State = Uninitialized | Idle | CheckingForUpdates | AvailableForDown
6262
export const State = {
6363
Uninitialized: { type: StateType.Uninitialized } as Uninitialized,
6464
Idle: { type: StateType.Idle } as Idle,
65-
CheckingForUpdates: (explicit: boolean) => ({ type: StateType.CheckingForUpdates, explicit } as CheckingForUpdates),
65+
CheckingForUpdates: (context: any) => ({ type: StateType.CheckingForUpdates, context } as CheckingForUpdates),
6666
AvailableForDownload: (update: IUpdate) => ({ type: StateType.AvailableForDownload, update } as AvailableForDownload),
6767
Downloading: (update: IUpdate) => ({ type: StateType.Downloading, update } as Downloading),
6868
Downloaded: (update: IUpdate) => ({ type: StateType.Downloaded, update } as Downloaded),
@@ -85,7 +85,7 @@ export interface IUpdateService {
8585
readonly onStateChange: Event<State>;
8686
readonly state: State;
8787

88-
checkForUpdates(explicit: boolean): TPromise<void>;
88+
checkForUpdates(context: any): TPromise<void>;
8989
downloadUpdate(): TPromise<void>;
9090
applyUpdate(): TPromise<void>;
9191
quitAndInstall(): TPromise<void>;

src/vs/platform/update/common/updateIpc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
1212
import { IUpdateService, State } from './update';
1313

1414
export interface IUpdateChannel extends IChannel {
15-
call(command: 'checkForUpdates', arg: boolean): TPromise<void>;
15+
call(command: 'checkForUpdates', arg: any): TPromise<void>;
1616
call(command: 'downloadUpdate'): TPromise<void>;
1717
call(command: 'applyUpdate'): TPromise<void>;
1818
call(command: 'quitAndInstall'): TPromise<void>;
@@ -62,8 +62,8 @@ export class UpdateChannelClient implements IUpdateService {
6262
}, onUnexpectedError);
6363
}
6464

65-
checkForUpdates(explicit: boolean): TPromise<void> {
66-
return this.channel.call('checkForUpdates', explicit);
65+
checkForUpdates(context: any): TPromise<void> {
66+
return this.channel.call('checkForUpdates', context);
6767
}
6868

6969
downloadUpdate(): TPromise<void> {

src/vs/platform/update/electron-main/abstractUpdateService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export abstract class AbstractUpdateService implements IUpdateService {
8181

8282
private scheduleCheckForUpdates(delay = 60 * 60 * 1000): TPromise<void> {
8383
return TPromise.timeout(delay)
84-
.then(() => this.checkForUpdates())
84+
.then(() => this.checkForUpdates(null))
8585
.then(update => {
8686
if (update) {
8787
// Update found, no need to check more
@@ -93,14 +93,14 @@ export abstract class AbstractUpdateService implements IUpdateService {
9393
});
9494
}
9595

96-
checkForUpdates(explicit = false): TPromise<void> {
96+
checkForUpdates(context: any): TPromise<void> {
9797
this.logService.trace('update#checkForUpdates, state = ', this.state.type);
9898

9999
if (this.state.type !== StateType.Idle) {
100100
return TPromise.as(null);
101101
}
102102

103-
return this.throttler.queue(() => TPromise.as(this.doCheckForUpdates(explicit)));
103+
return this.throttler.queue(() => TPromise.as(this.doCheckForUpdates(context)));
104104
}
105105

106106
downloadUpdate(): TPromise<void> {
@@ -158,5 +158,5 @@ export abstract class AbstractUpdateService implements IUpdateService {
158158
}
159159

160160
protected abstract setUpdateFeedUrl(quality: string): boolean;
161-
protected abstract doCheckForUpdates(explicit: boolean): void;
161+
protected abstract doCheckForUpdates(context: any): void;
162162
}

src/vs/platform/update/electron-main/updateService.darwin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export class DarwinUpdateService extends AbstractUpdateService {
5959
return true;
6060
}
6161

62-
protected doCheckForUpdates(explicit: boolean): void {
63-
this.setState(State.CheckingForUpdates(explicit));
62+
protected doCheckForUpdates(context: any): void {
63+
this.setState(State.CheckingForUpdates(context));
6464
electron.autoUpdater.checkForUpdates();
6565
}
6666

@@ -97,7 +97,7 @@ export class DarwinUpdateService extends AbstractUpdateService {
9797
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
9898
}
9999
*/
100-
this.telemetryService.publicLog('update:notAvailable', { explicit: this.state.explicit });
100+
this.telemetryService.publicLog('update:notAvailable', { explicit: !!this.state.context });
101101

102102
this.setState(State.Idle);
103103
}

src/vs/platform/update/electron-main/updateService.linux.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ export class LinuxUpdateService extends AbstractUpdateService {
4040
return true;
4141
}
4242

43-
protected doCheckForUpdates(explicit: boolean): void {
43+
protected doCheckForUpdates(context: any): void {
4444
if (!this.url) {
4545
return;
4646
}
4747

48-
this.setState(State.CheckingForUpdates(explicit));
48+
this.setState(State.CheckingForUpdates(context));
4949

5050
this.requestService.request({ url: this.url })
5151
.then<IUpdate>(asJson)
@@ -56,7 +56,7 @@ export class LinuxUpdateService extends AbstractUpdateService {
5656
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
5757
}
5858
*/
59-
this.telemetryService.publicLog('update:notAvailable', { explicit });
59+
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
6060

6161
this.setState(State.Idle);
6262
} else {
@@ -71,7 +71,7 @@ export class LinuxUpdateService extends AbstractUpdateService {
7171
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
7272
}
7373
*/
74-
this.telemetryService.publicLog('update:notAvailable', { explicit });
74+
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
7575
this.setState(State.Idle);
7676
});
7777
}

src/vs/platform/update/electron-main/updateService.win32.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ export class Win32UpdateService extends AbstractUpdateService {
7676
return true;
7777
}
7878

79-
protected doCheckForUpdates(explicit: boolean): void {
79+
protected doCheckForUpdates(context: any): void {
8080
if (!this.url) {
8181
return;
8282
}
8383

84-
this.setState(State.CheckingForUpdates(explicit));
84+
this.setState(State.CheckingForUpdates(context));
8585

8686
this.requestService.request({ url: this.url })
8787
.then<IUpdate>(asJson)
@@ -92,7 +92,7 @@ export class Win32UpdateService extends AbstractUpdateService {
9292
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
9393
}
9494
*/
95-
this.telemetryService.publicLog('update:notAvailable', { explicit });
95+
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
9696

9797
this.setState(State.Idle);
9898
return TPromise.as(null);
@@ -137,7 +137,7 @@ export class Win32UpdateService extends AbstractUpdateService {
137137
"explicit" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
138138
}
139139
*/
140-
this.telemetryService.publicLog('update:notAvailable', { explicit });
140+
this.telemetryService.publicLog('update:notAvailable', { explicit: !!context });
141141
this.setState(State.Idle);
142142
});
143143
}

src/vs/workbench/parts/update/electron-browser/update.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { OS } from 'vs/base/common/platform';
3333
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
3434
import { INotificationService } from 'vs/platform/notification/common/notification';
3535
import { IChoiceService } from 'vs/platform/dialogs/common/dialogs';
36+
import { IWindowService } from 'vs/platform/windows/common/windows';
3637

3738
const NotNowAction = new Action(
3839
'update.later',
@@ -299,7 +300,8 @@ export class UpdateContribution implements IGlobalActivity {
299300
@IChoiceService private choiceService: IChoiceService,
300301
@IUpdateService private updateService: IUpdateService,
301302
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
302-
@IActivityService private activityService: IActivityService
303+
@IActivityService private activityService: IActivityService,
304+
@IWindowService private windowService: IWindowService
303305
) {
304306
this.state = updateService.state;
305307

@@ -327,7 +329,7 @@ export class UpdateContribution implements IGlobalActivity {
327329
private onUpdateStateChange(state: UpdateState): void {
328330
switch (state.type) {
329331
case StateType.Idle:
330-
if (this.state.type === StateType.CheckingForUpdates && this.state.explicit) {
332+
if (this.state.type === StateType.CheckingForUpdates && this.state.context && this.state.context.windowId === this.windowService.getCurrentWindowId()) {
331333
this.onUpdateNotAvailable();
332334
}
333335
break;
@@ -492,8 +494,9 @@ export class UpdateContribution implements IGlobalActivity {
492494
return null;
493495

494496
case StateType.Idle:
497+
const windowId = this.windowService.getCurrentWindowId();
495498
return new Action('update.check', nls.localize('checkForUpdates', "Check for Updates..."), undefined, true, () =>
496-
this.updateService.checkForUpdates(true));
499+
this.updateService.checkForUpdates({ windowId }));
497500

498501
case StateType.CheckingForUpdates:
499502
return new Action('update.checking', nls.localize('checkingForUpdates', "Checking For Updates..."), undefined, false);

0 commit comments

Comments
 (0)