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

fixes #90632 (#90675)

上级 8bac0089
......@@ -127,39 +127,41 @@ export class ProductContribution implements IWorkbenchContribution {
@IHostService hostService: IHostService,
@IProductService productService: IProductService
) {
if (!hostService.hasFocus) {
return;
}
hostService.hadLastFocus().then(hadLastFocus => {
if (!hadLastFocus) {
return;
}
const lastVersion = storageService.get(ProductContribution.KEY, StorageScope.GLOBAL, '');
const shouldShowReleaseNotes = configurationService.getValue<boolean>('update.showReleaseNotes');
// was there an update? if so, open release notes
const releaseNotesUrl = productService.releaseNotesUrl;
if (shouldShowReleaseNotes && !environmentService.args['skip-release-notes'] && releaseNotesUrl && lastVersion && productService.version !== lastVersion) {
showReleaseNotes(instantiationService, productService.version)
.then(undefined, () => {
notificationService.prompt(
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),
[{
label: nls.localize('releaseNotes', "Release Notes"),
run: () => {
const uri = URI.parse(releaseNotesUrl);
openerService.open(uri);
}
}],
{ sticky: true }
);
});
}
const lastVersion = storageService.get(ProductContribution.KEY, StorageScope.GLOBAL, '');
const shouldShowReleaseNotes = configurationService.getValue<boolean>('update.showReleaseNotes');
// was there an update? if so, open release notes
const releaseNotesUrl = productService.releaseNotesUrl;
if (shouldShowReleaseNotes && !environmentService.args['skip-release-notes'] && releaseNotesUrl && lastVersion && productService.version !== lastVersion) {
showReleaseNotes(instantiationService, productService.version)
.then(undefined, () => {
notificationService.prompt(
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),
[{
label: nls.localize('releaseNotes', "Release Notes"),
run: () => {
const uri = URI.parse(releaseNotesUrl);
openerService.open(uri);
}
}],
{ sticky: true }
);
});
}
// should we show the new license?
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));
}
// should we show the new license?
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));
}
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 {
return document.hasFocus();
}
async hadLastFocus(): Promise<boolean> {
return true;
}
async focus(): Promise<void> {
window.focus();
}
......
......@@ -25,6 +25,11 @@ export interface IHostService {
*/
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.
*/
......
......@@ -36,6 +36,16 @@ export class DesktopHostService extends Disposable implements IHostService {
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(toOpen: IWindowOpenable[], options?: IOpenWindowOptions): Promise<void>;
openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> {
......
......@@ -865,6 +865,7 @@ export class TestHostService implements IHostService {
_serviceBrand: undefined;
readonly hasFocus: boolean = true;
async hadLastFocus(): Promise<boolean> { return true; }
readonly onDidChangeFocus: Event<boolean> = Event.None;
async restart(): Promise<void> { }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册