未验证 提交 7bc12be7 编写于 作者: J João Moreno 提交者: GitHub

fixes #90632 (#90675)

上级 8bac0089
...@@ -127,39 +127,41 @@ export class ProductContribution implements IWorkbenchContribution { ...@@ -127,39 +127,41 @@ export class ProductContribution implements IWorkbenchContribution {
@IHostService hostService: IHostService, @IHostService hostService: IHostService,
@IProductService productService: IProductService @IProductService productService: IProductService
) { ) {
if (!hostService.hasFocus) { hostService.hadLastFocus().then(hadLastFocus => {
return; if (!hadLastFocus) {
} return;
}
const lastVersion = storageService.get(ProductContribution.KEY, StorageScope.GLOBAL, ''); const lastVersion = storageService.get(ProductContribution.KEY, StorageScope.GLOBAL, '');
const shouldShowReleaseNotes = configurationService.getValue<boolean>('update.showReleaseNotes'); const shouldShowReleaseNotes = configurationService.getValue<boolean>('update.showReleaseNotes');
// was there an update? if so, open release notes // was there an update? if so, open release notes
const releaseNotesUrl = productService.releaseNotesUrl; const releaseNotesUrl = productService.releaseNotesUrl;
if (shouldShowReleaseNotes && !environmentService.args['skip-release-notes'] && releaseNotesUrl && lastVersion && productService.version !== lastVersion) { if (shouldShowReleaseNotes && !environmentService.args['skip-release-notes'] && releaseNotesUrl && lastVersion && productService.version !== lastVersion) {
showReleaseNotes(instantiationService, productService.version) showReleaseNotes(instantiationService, productService.version)
.then(undefined, () => { .then(undefined, () => {
notificationService.prompt( notificationService.prompt(
severity.Info, severity.Info,
nls.localize('read the release notes', "Welcome to {0} v{1}! Would you like to read the Release Notes?", productService.nameLong, productService.version), nls.localize('read the release notes', "Welcome to {0} v{1}! Would you like to read the Release Notes?", productService.nameLong, productService.version),
[{ [{
label: nls.localize('releaseNotes', "Release Notes"), label: nls.localize('releaseNotes', "Release Notes"),
run: () => { run: () => {
const uri = URI.parse(releaseNotesUrl); const uri = URI.parse(releaseNotesUrl);
openerService.open(uri); openerService.open(uri);
} }
}], }],
{ sticky: true } { sticky: true }
); );
}); });
} }
// should we show the new license? // should we show the new license?
if (productService.licenseUrl && lastVersion && semver.satisfies(lastVersion, '<1.0.0') && semver.satisfies(productService.version, '>=1.0.0')) { if (productService.licenseUrl && lastVersion && semver.satisfies(lastVersion, '<1.0.0') && semver.satisfies(productService.version, '>=1.0.0')) {
notificationService.info(nls.localize('licenseChanged', "Our license terms have changed, please click [here]({0}) to go through them.", productService.licenseUrl)); notificationService.info(nls.localize('licenseChanged', "Our license terms have changed, please click [here]({0}) to go through them.", productService.licenseUrl));
} }
storageService.store(ProductContribution.KEY, productService.version, StorageScope.GLOBAL); storageService.store(ProductContribution.KEY, productService.version, StorageScope.GLOBAL);
});
} }
} }
......
...@@ -95,6 +95,10 @@ export class BrowserHostService extends Disposable implements IHostService { ...@@ -95,6 +95,10 @@ export class BrowserHostService extends Disposable implements IHostService {
return document.hasFocus(); return document.hasFocus();
} }
async hadLastFocus(): Promise<boolean> {
return true;
}
async focus(): Promise<void> { async focus(): Promise<void> {
window.focus(); window.focus();
} }
......
...@@ -25,6 +25,11 @@ export interface IHostService { ...@@ -25,6 +25,11 @@ export interface IHostService {
*/ */
readonly hasFocus: boolean; readonly hasFocus: boolean;
/**
* Find out if the window had the last focus.
*/
hadLastFocus(): Promise<boolean>;
/** /**
* Attempt to bring the window to the foreground and focus it. * Attempt to bring the window to the foreground and focus it.
*/ */
......
...@@ -36,6 +36,16 @@ export class DesktopHostService extends Disposable implements IHostService { ...@@ -36,6 +36,16 @@ export class DesktopHostService extends Disposable implements IHostService {
return document.hasFocus(); return document.hasFocus();
} }
async hadLastFocus(): Promise<boolean> {
const activeWindowId = await this.electronService.getActiveWindowId();
if (typeof activeWindowId === 'undefined') {
return false;
}
return activeWindowId === this.electronEnvironmentService.windowId;
}
openWindow(options?: IOpenEmptyWindowOptions): Promise<void>; openWindow(options?: IOpenEmptyWindowOptions): Promise<void>;
openWindow(toOpen: IWindowOpenable[], options?: IOpenWindowOptions): Promise<void>; openWindow(toOpen: IWindowOpenable[], options?: IOpenWindowOptions): Promise<void>;
openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> { openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> {
......
...@@ -865,6 +865,7 @@ export class TestHostService implements IHostService { ...@@ -865,6 +865,7 @@ export class TestHostService implements IHostService {
_serviceBrand: undefined; _serviceBrand: undefined;
readonly hasFocus: boolean = true; readonly hasFocus: boolean = true;
async hadLastFocus(): Promise<boolean> { return true; }
readonly onDidChangeFocus: Event<boolean> = Event.None; readonly onDidChangeFocus: Event<boolean> = Event.None;
async restart(): Promise<void> { } async restart(): Promise<void> { }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册