Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/chat/common/blockedExtensionService.ts
13401 views
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 { createServiceIdentifier } from '../../../util/common/services';
7
8
export const IBlockedExtensionService = createServiceIdentifier<IBlockedExtensionService>('IBlockedExtensionService');
9
10
export interface IBlockedExtensionService {
11
readonly _serviceBrand: undefined;
12
13
reportBlockedExtension(extensionId: string, timeout: number): void;
14
isExtensionBlocked(extensionId: string): boolean;
15
}
16
17
export class BlockedExtensionService implements IBlockedExtensionService {
18
readonly _serviceBrand: undefined;
19
private blockedExtensions: Map<string, any> = new Map();
20
21
reportBlockedExtension(extensionId: string, timeout: number): void {
22
if (this.blockedExtensions.has(extensionId)) {
23
clearTimeout(this.blockedExtensions.get(extensionId)!);
24
}
25
26
const timer = setTimeout(() => {
27
this.blockedExtensions.delete(extensionId);
28
}, timeout * 1000);
29
this.blockedExtensions.set(extensionId, timer);
30
}
31
32
isExtensionBlocked(extensionId: string): boolean {
33
return this.blockedExtensions.has(extensionId);
34
}
35
}
36
37