Skip to content

Commit ae9f4c8

Browse files
committed
Use window with focus
1 parent bc4c0fb commit ae9f4c8

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/vs/workbench/parts/welcome/gettingStarted/electron-browser/telemetryOptOut.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
1414
import URI from 'vs/base/common/uri';
1515
import { localize } from 'vs/nls';
1616
import { onUnexpectedError } from 'vs/base/common/errors';
17+
import { IWindowService } from 'vs/platform/windows/common/windows';
1718

1819
export class TelemetryOptOut implements IWorkbenchContribution {
1920

@@ -24,17 +25,23 @@ export class TelemetryOptOut implements IWorkbenchContribution {
2425
@IEnvironmentService environmentService: IEnvironmentService,
2526
@IOpenerService openerService: IOpenerService,
2627
@INotificationService notificationService: INotificationService,
28+
@IWindowService windowService: IWindowService,
2729
@ITelemetryService telemetryService: ITelemetryService
2830
) {
2931
if (!product.telemetryOptOutUrl || storageService.get(TelemetryOptOut.TELEMETRY_OPT_OUT_SHOWN)) {
3032
return;
3133
}
32-
storageService.store(TelemetryOptOut.TELEMETRY_OPT_OUT_SHOWN, true);
34+
windowService.isFocused().then(focused => {
35+
if (!focused) {
36+
return null;
37+
}
38+
storageService.store(TelemetryOptOut.TELEMETRY_OPT_OUT_SHOWN, true);
3339

34-
const optOutUrl = product.telemetryOptOutUrl;
35-
const privacyUrl = product.privacyStatementUrl || product.telemetryOptOutUrl;
36-
notificationService.prompt(Severity.Info, localize('telemetryOptOut.notice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt out]({1}).", privacyUrl, optOutUrl), [localize('telemetryOptOut.readMore', "Read More")])
37-
.then(() => openerService.open(URI.parse(optOutUrl)))
40+
const optOutUrl = product.telemetryOptOutUrl;
41+
const privacyUrl = product.privacyStatementUrl || product.telemetryOptOutUrl;
42+
return notificationService.prompt(Severity.Info, localize('telemetryOptOut.notice', "Help improve VS Code by allowing Microsoft to collect usage data. Read our [privacy statement]({0}) and learn how to [opt out]({1}).", privacyUrl, optOutUrl), [localize('telemetryOptOut.readMore', "Read More")])
43+
.then(() => openerService.open(URI.parse(optOutUrl)));
44+
})
3845
.then(null, onUnexpectedError);
3946
}
4047
}

0 commit comments

Comments
 (0)