continue-custom/core/context/providers/CustomContextProvider.ts
Bjørn Jørgensen 1d14eb46ef
Prefer using nullish coalescing operator (??) instead of a logical or (#922)
* Prefer using nullish coalescing operator (`??`) instead of a logical or (`||`), as it is a safer operator.

* index.ts

* more...

* more..

* indenting

* fix indenting
2024-03-08 22:41:04 -08:00

38 lines
990 B
TypeScript

import {
ContextItem,
ContextProviderDescription,
ContextProviderExtras,
CustomContextProvider,
IContextProvider,
LoadSubmenuItemsArgs,
} from "../..";
class CustomContextProviderClass implements IContextProvider {
custom: CustomContextProvider;
constructor(custom: CustomContextProvider) {
this.custom = custom;
}
get description(): ContextProviderDescription {
return {
title: this.custom.title,
displayTitle: this.custom.displayTitle ?? this.custom.title,
description: this.custom.description ?? "",
type: this.custom.type ?? "normal",
renderInlineAs: this.custom.renderInlineAs,
};
}
async getContextItems(
query: string,
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
return await this.custom.getContextItems(query, extras);
}
async loadSubmenuItems(args: LoadSubmenuItemsArgs) {
return this.custom.loadSubmenuItems?.(args) ?? [];
}
}
export default CustomContextProviderClass;