Skip to content

Commit

Permalink
fix: app store ui not updating to show installing plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 committed Jan 29, 2025
1 parent dfcc14e commit cbfa231
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,10 @@ function isTheServerModule(moduleName: string, config: Config) {
return moduleName === config.name
}

const modulesByKeyword: { [key: string]: any } = {}

function findModulesWithKeyword(keyword: string) {
return new Promise((resolve, reject) => {
let errorCount = 0
const result = {}
const handleResultWithTimeout = (fetchResult: Promise<Response>): void => {
fetchResult
Expand All @@ -236,20 +237,31 @@ function findModulesWithKeyword(keyword: string) {
},
result
)
resolve(_.values(result))
const packages = _.values(result)
modulesByKeyword[keyword] = {
time: Date.now(),
packages
}
resolve(packages)
})
.catch((e) => {
if (errorCount++) {
reject(e)
}
reject(e)
})
}
;[
if (
modulesByKeyword[keyword] &&
Date.now() - modulesByKeyword[keyword].time < 60 * 1000
) {
resolve(modulesByKeyword[keyword].packages)
return
}

handleResultWithTimeout(
fetch(
'http://registry.npmjs.org/-/v1/search?size=250&text=keywords:' +
keyword
)
].forEach(handleResultWithTimeout)
)
})
}

Expand Down

0 comments on commit cbfa231

Please sign in to comment.