Skip to content

Commit e25b3e7

Browse files
committed
refactor: minor: cleanup marketplaceHandler passing
1 parent 3dcb453 commit e25b3e7

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/core/webview/webviewMessageHandler.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ import { handleMarketplaceMessages } from "./marketplaceMessageHandler"
4242
import { MultiSearchReplaceDiffStrategy } from "../diff/strategies/multi-search-replace"
4343
import { getModels } from "../../api/providers/fetchers/cache"
4444

45+
const marketplaceMessages = new Set([
46+
"marketplaceSources",
47+
"openExternal",
48+
"fetchMarketplaceItems",
49+
"installMarketplaceItem",
50+
"installMarketplaceItemWithParameters",
51+
"cancelMarketplaceInstall",
52+
"refreshMarketplaceSource",
53+
"filterMarketplaceItems",
54+
])
55+
4556
export const webviewMessageHandler = async (
4657
provider: ClineProvider,
4758
message: WebviewMessage,
@@ -147,17 +158,6 @@ export const webviewMessageHandler = async (
147158

148159
provider.isViewLaunched = true
149160
break
150-
case "fetchMarketplaceItems":
151-
if (marketplaceManager) {
152-
try {
153-
await handleMarketplaceMessages(provider, message, marketplaceManager!)
154-
} catch (error) {
155-
console.error(`DEBUG: Error handling marketplace message: ${error}`)
156-
}
157-
} else {
158-
console.log(`DEBUG: marketplaceManager is undefined, skipping marketplace message handling`)
159-
}
160-
break
161161
case "newTask":
162162
// Code that should run in response to the hello message command
163163
//vscode.window.showInformationMessage(message.text!)
@@ -1278,16 +1278,7 @@ export const webviewMessageHandler = async (
12781278
}
12791279
}
12801280

1281-
if (
1282-
marketplaceManager &&
1283-
(message.type === "marketplaceSources" ||
1284-
message.type === "openExternal" ||
1285-
message.type === "installMarketplaceItem" ||
1286-
message.type === "installMarketplaceItemWithParameters" ||
1287-
message.type === "cancelMarketplaceInstall" ||
1288-
message.type === "refreshMarketplaceSource" ||
1289-
message.type === "filterMarketplaceItems")
1290-
) {
1281+
if (marketplaceManager && marketplaceMessages.has(message.type)) {
12911282
try {
12921283
console.log(`DEBUG: Routing ${message.type} message to marketplaceMessageHandler`)
12931284
const result = await handleMarketplaceMessages(provider, message, marketplaceManager)

0 commit comments

Comments
 (0)