Skip to content

Commit

Permalink
Fixing the GitHub importer to not request each time an extension is d…
Browse files Browse the repository at this point in the history
…ownloaded
  • Loading branch information
raguay committed Apr 27, 2022
1 parent 170efc1 commit 60ec2be
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 55 deletions.
111 changes: 56 additions & 55 deletions frontend/src/components/GitHub.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
const dispatch = createEventDispatcher();
let octok;
let repos;
let themes;
let repos = null;
let themes = null;
let width = null;
let msgs = [];
let pickerDOM;
Expand Down Expand Up @@ -46,37 +46,38 @@
}
async function loadRepoInfo() {
console.log("loading repo info:");
loading = true;
if (typeof repos !== "undefined") {
repos = {};
}
if (typeof themes !== "undefined") {
themes = {};
}
var repost = await octok.search.repos({
q: "topic:modalfilemanager+topic:extension+topic:v2",
});
if (check(repost)) {
repost = repost.data.items;
console.log(repost);
for (var i = 0; i < repost.length; i++) {
console.log(repost[i]);
repost[i].loaded = await extExists(repost[i]);
if (repos === null && themes === null) {
loading = true;
if (typeof repos !== "undefined") {
repos = {};
}
repos = repost;
}
var themest = await octok.search.repos({
q: "topic:modalfilemanager+topic:theme",
});
if (check(themest)) {
themest = themest.data.items;
for (var i = 0; i < themest.length; i++) {
themest[i].loaded = await themeExists(themest[i]);
if (typeof themes !== "undefined") {
themes = {};
}
var repost = await octok.search.repos({
q: "topic:modalfilemanager+topic:extension+topic:v2",
});
if (check(repost)) {
repost = repost.data.items;
for (var i = 0; i < repost.length; i++) {
repost[i].loaded = await extExists(repost[i]);
}
repos = repost;
}
themes = themest;
var themest = await octok.search.repos({
q: "topic:modalfilemanager+topic:theme",
});
if (check(themest)) {
themest = themest.data.items;
for (var i = 0; i < themest.length; i++) {
themest[i].loaded = await themeExists(themest[i]);
}
themes = themest;
}
loading = false;
}
loading = false;
repos = repos;
themes = themes;
}
function getHeight() {
Expand Down Expand Up @@ -135,7 +136,6 @@
theme.set(newTheme);
addMsg(thm, "This theme is now being used.");
} else {
console.log("The theme doesn't have a package.json file.");
addMsg(thm, "The theme doesn't have a package.json file.");
}
}
Expand All @@ -151,17 +151,19 @@
async function deleteTheme(thm) {
var confg = get(config);
var thmDir = await confg.OS.appendPath(confg.configDir, "themes");
thmDir = await confg.OS.appendPath(thmDir, thm.name);
//
// #TODO - make it not a command line.
//
await confg.OS.runCommandLine(
'rm -Rf "' + thmDir + '";',
[],
(err, stdin, stdout) => {
loadRepoInfo();
await confg.OS.deleteEntries(
{
name: thm.name,
dir: thmDir,
},
"."
() => {
themes = themes.map((item) => {
if (item.name === thm.name) {
item.loaded = false;
}
return item;
});
}
);
}
Expand All @@ -184,34 +186,33 @@
}
async function extExists(ext) {
console.log("Ext exists...");
var confg = get(config);
var extDir = await confg.OS.appendPath(confg.configDir, "extensions");
extDir = await confg.OS.appendPath(extDir, ext.name);
console.log(extDir);
var flag = await confg.OS.dirExists(extDir);
console.log(flag);
return flag;
}
async function deleteExtension(ext) {
var confg = get(config);
var extDir = await confg.OS.appendPath(confg.configDir, "extensions");
extDir = await confg.OS.appendPath(extDir, ext.name);
//
// #TODO = change to not using command line.
//
await confg.OS.runCommandLine(
'rm -Rf "' + extDir + '";',
[],
(err, stdin, stdout) => {
loadRepoInfo();
await confg.OS.deleteEntries(
{
name: ext.name,
dir: extDir,
},
() => {
repos = repos.map((item) => {
if (item.name === ext.name) {
item.loaded = false;
}
return item;
});
addMsg(
ext,
"Rerun the application to remove the extension from memory."
);
},
"."
}
);
}
Expand Down
1 change: 1 addition & 0 deletions frontend/wailsjs/go/bindings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface go {
GetEnvironment():Promise<Array<string>>
GetError():Promise<string>
GetHomeDir():Promise<string>
GetOSName():Promise<string>
MakeDir(arg1:string):Promise<void>
MakeFile(arg1:string):Promise<void>
MoveEntries(arg1:string,arg2:string):Promise<void>
Expand Down
7 changes: 7 additions & 0 deletions frontend/wailsjs/go/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ const go = {
"GetHomeDir": () => {
return window.go.main.App.GetHomeDir();
},
/**
* GetOSName
* @returns {Promise<string>} - Go Type: string
*/
"GetOSName": () => {
return window.go.main.App.GetOSName();
},
/**
* MakeDir
* @param {string} arg1 - Go Type: string
Expand Down

0 comments on commit 60ec2be

Please sign in to comment.