better code: removed dead code
Massimo Melina committed
Aug 31, 2023 at 16:25 UTC
4bce78c5caad40572d569b8c03cbdee2c968fb1a
2 files changed
+2
-11
src/api.plugins.ts
+1
-10
@@ -117,12 +117,7 @@ const apis: ApiHandlers = {
117
const folder2repo = getFolder2repo()
118
for await (const pl of searchPlugins(text)) {
119
const repo = pl.id
120
- if (_.includes(folder2repo, repo)) continue
121
- const folder = _.findKey(folder2repo, x => x === repo)
122
- const installed = folder && getPluginInfo(folder)
123
- Object.assign(pl, {
124
- update: installed && installed.version < pl.version!,
125
- })
120
+ if (_.includes(folder2repo, repo)) continue // don't include installed plugins
121
list.add(pl)
122
// watch for events about this plugin, until this request is closed
123
undo.push(onOff(events, {
@@ -134,10 +129,6 @@ const apis: ApiHandlers = {
129
if (repo === getFolder2repo()[folder])
130
list.update({ id: repo }, { installed: false })
131
},
137
- pluginUpdated: p => {
138
- if (p.repo === repo)
139
- list.update({ id: repo }, { update: p.version < pl.version! })
140
- },
132
['pluginDownload_' + repo](status) {
133
list.update({ id: repo }, { downloading: status ?? null })
134
}
src/github.ts
+1
-1
@@ -55,7 +55,7 @@ export async function downloadPlugin(repo: string, branch='', overwrite?: boolea
55
if (!short)
56
return new ApiError(HTTP_BAD_REQUEST, "bad repo")
57
const folder = overwrite ? _.findKey(getFolder2repo(), x => x===repo)! // use existing folder
58
- : getFolder2repo().hasOwnProperty(short) ? repo.replace('/','-') // longer form only if another plugin is using short form
58
+ : getFolder2repo().hasOwnProperty(short) ? repo.replace('/','-') // longer form only if another plugin is using short form, to avoid overwriting
59
: short
60
const GITHUB_ZIP_ROOT = short + '-' + branch // GitHub puts everything within this folder
61
return await go(`https://github.com/${repo}/archive/refs/heads/${branch}.zip`, folder, GITHUB_ZIP_ROOT + '/' + DIST_ROOT)