|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +import { IWorkbenchContribution } from '../../../../common/contributions.js'; |
| 7 | +import { Disposable } from '../../../../../base/common/lifecycle.js'; |
| 8 | +import { IProductService } from '../../../../../platform/product/common/productService.js'; |
| 9 | +import { ICommandService } from '../../../../../platform/commands/common/commands.js'; |
| 10 | +import { IExtensionService } from '../../../../services/extensions/common/extensions.js'; |
| 11 | +import { ExtensionIdentifier } from '../../../../../platform/extensions/common/extensions.js'; |
| 12 | +import { CHAT_OPEN_ACTION_ID } from './chatActions.js'; |
| 13 | + |
| 14 | + |
| 15 | +export class ChatGettingStartedContribution extends Disposable implements IWorkbenchContribution { |
| 16 | + static readonly ID = 'workbench.contrib.chatGettingStarted'; |
| 17 | + private recentlyInstalled: boolean = false; |
| 18 | + |
| 19 | + constructor( |
| 20 | + @IProductService private readonly productService: IProductService, |
| 21 | + @IExtensionService private readonly extensionService: IExtensionService, |
| 22 | + @ICommandService private readonly commandService: ICommandService, |
| 23 | + ) { |
| 24 | + super(); |
| 25 | + |
| 26 | + if (!this.productService.gitHubEntitlement) { |
| 27 | + return; |
| 28 | + } |
| 29 | + |
| 30 | + this.registerListeners(); |
| 31 | + } |
| 32 | + |
| 33 | + private registerListeners() { |
| 34 | + |
| 35 | + this._register(this.extensionService.onDidChangeExtensions((result) => { |
| 36 | + for (const ext of result.added) { |
| 37 | + if (ExtensionIdentifier.equals(this.productService.gitHubEntitlement!.extensionId, ext.identifier)) { |
| 38 | + this.recentlyInstalled = true; |
| 39 | + return; |
| 40 | + } |
| 41 | + } |
| 42 | + })); |
| 43 | + |
| 44 | + this.extensionService.onDidChangeExtensionsStatus(async (event) => { |
| 45 | + for (const ext of event) { |
| 46 | + if (ExtensionIdentifier.equals(this.productService.gitHubEntitlement!.extensionId, ext.value)) { |
| 47 | + const extensionStatus = this.extensionService.getExtensionsStatus(); |
| 48 | + if (extensionStatus[ext.value].activationTimes && this.recentlyInstalled) { |
| 49 | + await this.commandService.executeCommand(CHAT_OPEN_ACTION_ID); |
| 50 | + this.recentlyInstalled = false; |
| 51 | + return; |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + }); |
| 56 | + } |
| 57 | +} |
0 commit comments