Skip to content

Commit ecc7cf9

Browse files
ChristophLHRColdIV
andcommitted
removed redundant refresh
Co-authored-by: Josh <[email protected]>
1 parent 39d74f2 commit ecc7cf9

File tree

2 files changed

+4
-53
lines changed

2 files changed

+4
-53
lines changed

libs/scm/autocomplete.lua

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -177,55 +177,6 @@ $ help <name>
177177
self.commands["help"]["args"] = availableCommands
178178
end
179179

180-
function Autocomplete:refreshRepoScripts()
181-
log("Downloading program and library names from GitHub...")
182-
local repoScripts = {}
183-
184-
local programs = {}
185-
local libraries = {}
186-
187-
local request = http.get(SCM.Config.getAll(SCM.Config)["apiGithubURL"]
188-
.. SCM.Config.getAll(SCM.Config)["user"]
189-
.. SCM.Config.getAll(SCM.Config)["apiGithubGetRepos"])
190-
if request then
191-
local response = request.readAll()
192-
request.close()
193-
194-
local responseTable = textutils.unserializeJSON(response)
195-
196-
local programSuffix = SCM.Config.getAll(SCM.Config)["programSuffix"]
197-
local librarySuffix = SCM.Config.getAll(SCM.Config)["librarySuffix"]
198-
199-
for i = 1, #responseTable, 1 do
200-
local scriptName = responseTable[i]["name"]
201-
if string.sub(scriptName, -string.len(programSuffix)) == programSuffix then
202-
programs[
203-
string.sub(scriptName, 0, string.len(scriptName) - string.len(programSuffix))
204-
] = {}
205-
elseif string.sub(scriptName, -string.len(librarySuffix)) == librarySuffix then
206-
libraries[
207-
string.sub(scriptName, 0, string.len(scriptName) - string.len(librarySuffix))
208-
] = {}
209-
end
210-
end
211-
else
212-
log("Download failed")
213-
end
214-
215-
self.commands["add"]["args"] = programs
216-
self.commands["require"]["args"] = libraries
217-
218-
repoScripts["libraries"] = libraries
219-
repoScripts["programs"] = programs
220-
221-
local file = fs.open(SCM.Config.getAll(SCM.Config)["configDirectory"]
222-
.. SCM.Config.getAll(SCM.Config)["repoScriptsFile"], "w")
223-
if file then
224-
file.write(textutils.serializeJSON(repoScripts))
225-
file.close()
226-
end
227-
end
228-
229180
---@param shell table
230181
---@param index integer
231182
---@param argument string
@@ -260,13 +211,13 @@ $ help <name>
260211
end
261212

262213
function Autocomplete:refreshAutocomplete()
263-
self:refreshRepoScripts()
214+
SCM.Net:refreshRepoScripts()
264215
self:prepareAutocomplete()
265216
self:updateAutocomplete()
266217
end
267218

268219
---@param t table
269-
function Autocomplete:setProgramms(t)
220+
function Autocomplete:setPrograms(t)
270221
self.commands["add"]["args"] = t
271222
end
272223

libs/scm/net.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ do
244244
else
245245
local repoScripts = textutils.unserializeJSON(file.readAll()) or nil
246246
if repoScripts then
247-
SCM.Autocomplete:setProgramms(repoScripts["programs"])
247+
SCM.Autocomplete:setPrograms(repoScripts["programs"])
248248
SCM.Autocomplete:setLibaries(repoScripts["libraries"])
249249
end
250250

@@ -284,7 +284,7 @@ do
284284
log("Download failed")
285285
end
286286

287-
SCM.Autocomplete:setProgramms(programs)
287+
SCM.Autocomplete:setPrograms(programs)
288288
SCM.Autocomplete:setLibaries(libraries)
289289

290290
repoScripts["libraries"] = libraries

0 commit comments

Comments
 (0)