Skip to content

Commit 693babe

Browse files
committed
Test event
1 parent 5e2b70e commit 693babe

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
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.83",
3+
"version": "0.1.84",
44
"main": "dist/main.js",
55
"typings": "dist/index.d.ts",
66
"files": [

src/components/FileEditor/FileEditor.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react";
33
import { SaveIcon, MinusIcon, PlusIcon } from "Assets";
44
import { publish, subscribe, unsubscribe, useError, useTheme } from "Utils";
55
import { CommsManager } from "jderobot-commsmanager";
6-
import { Entry, EditorsEntry } from "Types";
6+
import { Entry, EditorsEntry, Options } from "Types";
77
import TextEditor from "./TextEditor";
88
import {
99
MenuButton,
@@ -36,6 +36,7 @@ const FileEditor = ({
3636
api,
3737
extraEditors,
3838
splashIcon,
39+
options,
3940
}: {
4041
currentFile?: Entry;
4142
changeCurrentFile: Function;
@@ -45,11 +46,14 @@ const FileEditor = ({
4546
api: ExtraApi;
4647
splashIcon: JSX.Element;
4748
extraEditors: EditorsEntry[];
49+
options?: Options;
4850
}) => {
4951
const { error, warning } = useError();
5052
const theme = useTheme();
5153

52-
const [fileContent, _setFileContent] = useState<string | undefined>(undefined);
54+
const [fileContent, _setFileContent] = useState<string | undefined>(
55+
undefined
56+
);
5357
const [zoomLevel, changeZoomLevel] = useState(0);
5458
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
5559
const [fileToSave, _setFileToSave] = useState<Entry | undefined>(undefined);
@@ -71,17 +75,25 @@ const FileEditor = ({
7175
_setFileContent(data);
7276
};
7377

74-
7578
useEffect(() => {
7679
subscribe("autoSave", async () => {
7780
if (autosave) {
7881
await autoSave();
79-
publish("autoSaveCompleted")
82+
publish("autoSaveCompleted");
8083
}
8184
});
8285

86+
if (options?.editor?.onlyOneFile) {
87+
subscribe("uploadOnlyCode", (e: any) => {
88+
setFileContent(e.detail.code);
89+
});
90+
}
91+
8392
return () => {
8493
unsubscribe("autoSave", () => {});
94+
if (options?.editor?.onlyOneFile) {
95+
unsubscribe("uploadOnlyCode", () => {});
96+
}
8597
};
8698
}, []);
8799

src/components/IdeInterface/IdeInterface.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ const IdeInterface = ({
6767
}: IdeInterfaceProps) => {
6868
const theme = useTheme();
6969

70-
var [currentFile, setCurrentFile] = useState<Entry | undefined>(undefined);
71-
72-
if (baseFile && options?.editor?.onlyOneFile) {
73-
setCurrentFile = () => {}
74-
}
70+
var [currentFile, setCurrentFile] = useState<Entry | undefined>(baseFile);
7571

7672
if (splashIcon === undefined) {
7773
splashIcon = (
@@ -100,7 +96,7 @@ const IdeInterface = ({
10096
{explorers.map((explorer) => (
10197
<Explorer
10298
setCurrentFile={setCurrentFile}
103-
currentFile={baseFile && options?.editor?.onlyOneFile ? baseFile : currentFile}
99+
currentFile={currentFile}
104100
project={project}
105101
api={explorer}
106102
/>
@@ -110,14 +106,15 @@ const IdeInterface = ({
110106
<StyledIdeVertContainer bgColor={theme.palette?.primary}>
111107
<StyledIdeContainer bgColor={theme.palette?.background}>
112108
<FileEditor
113-
currentFile={baseFile && options?.editor?.onlyOneFile ? baseFile : currentFile}
109+
currentFile={currentFile}
114110
changeCurrentFile={setCurrentFile}
115111
currentProjectname={project}
116112
autosave={true}
117113
manager={commsManager}
118114
api={api}
119115
extraEditors={extraEditors}
120116
splashIcon={splashIcon}
117+
options={options}
121118
/>
122119
</StyledIdeContainer>
123120
</StyledIdeVertContainer>

0 commit comments

Comments
 (0)