Skip to content

Commit

Permalink
Merge pull request #183887 from microsoft/dev/bhavyau/welcome-widget
Browse files Browse the repository at this point in the history
Remove check for context keys
  • Loading branch information
meganrogge committed May 31, 2023
2 parents de70014 + b6fb17e commit 5c01360
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 38 deletions.
5 changes: 0 additions & 5 deletions src/vs/workbench/browser/web.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,6 @@ export interface IWelcomeDialog {
*/
message: string;

/**
* Context key expression to control the visibility of the welcome dialog.
*/
when: string;

/**
* Media to include in the welcome dialog.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { Disposable } from 'vs/base/common/lifecycle';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ICommandService } from 'vs/platform/commands/common/commands';
Expand All @@ -28,12 +28,12 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions, Configur
import { localize } from 'vs/nls';
import { applicationConfigurationNodeBase } from 'vs/workbench/common/configuration';
import { RunOnceScheduler } from 'vs/base/common/async';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';

const configurationKey = 'workbench.welcome.experimental.dialog';

class WelcomeDialogContribution extends Disposable implements IWorkbenchContribution {

private contextKeysToWatch = new Set<string>();
private isRendered = false;

constructor(
Expand All @@ -50,7 +50,8 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu
@IFileService readonly fileService: IFileService,
@INotificationService readonly notificationService: INotificationService,
@IExtensionService readonly extensionService: IExtensionService,
@ILanguageService readonly languageService: LanguageService
@ILanguageService readonly languageService: LanguageService,
@IEditorService readonly editorService: IEditorService
) {
super();

Expand All @@ -68,46 +69,38 @@ class WelcomeDialogContribution extends Disposable implements IWorkbenchContribu
return;
}

this.contextKeysToWatch.add(welcomeDialog.when);

this._register(this.contextService.onDidChangeContext(e => {
if (e.affectsSome(this.contextKeysToWatch) && !this.isRendered) {

if (!Array.from(this.contextKeysToWatch).every(value => this.contextService.contextMatchesRules(ContextKeyExpr.deserialize(value)))) {
return;
}

const codeEditor = this.codeEditorService.getActiveCodeEditor();
this._register(editorService.onDidActiveEditorChange(() => {
if (!this.isRendered) {

const codeEditor = codeEditorService.getActiveCodeEditor();
if (codeEditor?.hasModel()) {
const scheduler = new RunOnceScheduler(() => {
this.isRendered = true;
const detailsRenderer = new GettingStartedDetailsRenderer(fileService, notificationService, extensionService, languageService);

const welcomeWidget = new WelcomeWidget(
codeEditor,
instantiationService,
commandService,
telemetryService,
openerService,
webviewService,
detailsRenderer);

welcomeWidget.render(welcomeDialog.title,
welcomeDialog.message,
welcomeDialog.buttonText,
welcomeDialog.buttonCommand,
welcomeDialog.media);

if (codeEditor === codeEditorService.getActiveCodeEditor()) {
this.isRendered = true;
const detailsRenderer = new GettingStartedDetailsRenderer(fileService, notificationService, extensionService, languageService);

const welcomeWidget = new WelcomeWidget(
codeEditor,
instantiationService,
commandService,
telemetryService,
openerService,
webviewService,
detailsRenderer);

welcomeWidget.render(welcomeDialog.title,
welcomeDialog.message,
welcomeDialog.buttonText,
welcomeDialog.buttonCommand,
welcomeDialog.media);
}
}, 3000);

this._register(codeEditor.onDidChangeModelContent((e) => {
if (!this.isRendered) {
scheduler.schedule();
}
}));

this.contextKeysToWatch.delete(welcomeDialog.when);
}
}
}));
Expand Down

0 comments on commit 5c01360

Please sign in to comment.