MCPcopy Create free account
hub / github.com/codeaashu/claude-code / loadMarketplaceData

Function loadMarketplaceData

src/commands/plugin/BrowseMarketplace.tsx:126–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

124 // Load marketplaces and count installed plugins
125 useEffect(() => {
126 async function loadMarketplaceData() {
127 try {
128 const config = await loadKnownMarketplacesConfig();
129
130 // Load marketplaces with graceful degradation
131 const {
132 marketplaces: marketplaces_0,
133 failures
134 } = await loadMarketplacesWithGracefulDegradation(config);
135 const marketplaceInfos: MarketplaceInfo[] = [];
136 for (const {
137 name,
138 config: marketplaceConfig,
139 data: marketplace
140 } of marketplaces_0) {
141 if (marketplace) {
142 // Count how many plugins from this marketplace are installed
143 const installedFromThisMarketplace = count(marketplace.plugins, plugin => isPluginInstalled(createPluginId(plugin.name, name)));
144 marketplaceInfos.push({
145 name,
146 totalPlugins: marketplace.plugins.length,
147 installedCount: installedFromThisMarketplace,
148 source: getMarketplaceSourceDisplay(marketplaceConfig.source)
149 });
150 }
151 }
152
153 // Sort so claude-plugin-directory is always first
154 marketplaceInfos.sort((a, b) => {
155 if (a.name === 'claude-plugin-directory') return -1;
156 if (b.name === 'claude-plugin-directory') return 1;
157 return 0;
158 });
159 setMarketplaces(marketplaceInfos);
160
161 // Handle marketplace loading errors/warnings
162 const successCount = count(marketplaces_0, m => m.data !== null);
163 const errorResult = formatMarketplaceLoadingErrors(failures, successCount);
164 if (errorResult) {
165 if (errorResult.type === 'warning') {
166 setWarning(errorResult.message + '. Showing available marketplaces.');
167 } else {
168 throw new Error(errorResult.message);
169 }
170 }
171
172 // Skip marketplace selection if there's only one marketplace
173 if (marketplaceInfos.length === 1 && !targetMarketplace && !targetPlugin) {
174 const singleMarketplace = marketplaceInfos[0];
175 if (singleMarketplace) {
176 setSelectedMarketplace(singleMarketplace.name);
177 setViewState('plugin-list');
178 }
179 }
180
181 // Handle targetMarketplace and targetPlugin after marketplaces are loaded
182 if (targetPlugin) {
183 // Search for the plugin across all marketplaces

Callers 1

BrowseMarketplaceFunction · 0.85

Calls 10

countFunction · 0.85
isPluginInstalledFunction · 0.85
createPluginIdFunction · 0.85
entriesMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected