Skip to content

Commit 8532924

Browse files
committed
Change callback again
1 parent 03cec4f commit 8532924

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jderobot-ide-interface",
3-
"version": "0.1.62",
3+
"version": "0.1.63",
44
"main": "dist/main.js",
55
"typings": "dist/index.d.ts",
66
"files": [

src/components/Explorer/Explorer.tsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,21 @@ const Explorer = ({
9999

100100
const fetchFileListCallback = async (e: any) => {
101101
const project = e.detail.project;
102-
await fetchFileList(project !== undefined ? project : "");
102+
if (project !== undefined && project !== "") {
103+
try {
104+
const file_list = await api.list(project);
105+
const files = JSON.parse(file_list);
106+
setFileList(files);
107+
} catch (e) {
108+
if (e instanceof Error) {
109+
console.error("Error fetching files:", e);
110+
error("Error fetching files: " + e.message);
111+
}
112+
}
113+
}
103114
};
104115

105-
const fetchFileList = async (project: string) => {
116+
const fetchFileList = async () => {
106117
console.log("Fecthing file list, the project name is:", project);
107118
if (project !== "") {
108119
try {
@@ -157,7 +168,7 @@ const Explorer = ({
157168
if (name !== "") {
158169
try {
159170
await api.file.create(project, location, name);
160-
fetchFileList(project); // Update the file list
171+
fetchFileList(); // Update the file list
161172
} catch (e) {
162173
if (e instanceof Error) {
163174
console.error("Error creating file:", e);
@@ -196,7 +207,7 @@ const Explorer = ({
196207
await api.file.delete(project, deleteEntry.path);
197208
}
198209

199-
fetchFileList(project); // Update the file list
210+
fetchFileList(); // Update the file list
200211

201212
if (currentFile === deleteEntry) {
202213
setCurrentFile(undefined); // Unset the current file
@@ -250,7 +261,7 @@ const Explorer = ({
250261
if (folder_name !== "") {
251262
try {
252263
await api.folder.create(project, folder_name, location);
253-
fetchFileList(project); // Update the file list
264+
fetchFileList(); // Update the file list
254265
} catch (e) {
255266
if (e instanceof Error) {
256267
console.error("Error creating folder:", e.message);
@@ -289,7 +300,7 @@ const Explorer = ({
289300
await api.file.rename(project, renameEntry.path, new_path);
290301
}
291302

292-
fetchFileList(project); // Update the file list
303+
fetchFileList(); // Update the file list
293304

294305
if (currentFile && currentFile.path === renameEntry.path) {
295306
currentFile.path = new_path;
@@ -326,7 +337,7 @@ const Explorer = ({
326337

327338
const handleCloseUploadModal = () => {
328339
setUploadModalOpen(false);
329-
fetchFileList(project);
340+
fetchFileList();
330341
};
331342

332343
///////////////// DOWNLOAD ///////////////////////////////////////////////////
@@ -404,7 +415,7 @@ const Explorer = ({
404415
</MenuButtonStroke>
405416
<MenuButtonStroke
406417
id="refresh-explorer-button"
407-
onClick={() => fetchFileList(project)}
418+
onClick={() => fetchFileList()}
408419
title="Refresh View"
409420
>
410421
<ResetIcon viewBox="0 0 20 20" />
@@ -449,7 +460,7 @@ const Explorer = ({
449460
isOpen={isNewFileModalOpen}
450461
onSubmit={(project: string, location: string, ...args: any[]) => {
451462
api.modals!.createFile!.onCreate(project, location, ...args);
452-
fetchFileList(project);
463+
fetchFileList();
453464
}}
454465
onClose={handleCloseNewFileModal}
455466
fileList={fileList}

0 commit comments

Comments
 (0)