Skip to content

Commit cb0c2a8

Browse files
committed
chore: adds input/output collaborative
1 parent aa15822 commit cb0c2a8

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import Preview from './components/Preview';
1313

1414
function App() {
1515
const [textEditor, setTextEditor] = useState('input');
16-
const [output, setOutput] = useState('');
1716
const [processing, setProcessing] = useState(false);
1817
const [percentageStage, setPercentageStage] = useState(0);
1918
const [selected, setSelected] = useState('PYTHON');
2019
const [input, setInput] = useState('');
20+
const [output, setOutput] = useState('');
2121
const [python, setpython] = useState('');
2222
const [modal, setModal] = useState(false);
2323
const [docId, setDocId] = useState(null);

src/components/IDE.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Tabs, TabList, TabPanels, Tab, TabPanel, Skeleton, Progress, Tag } from
2121
import 'react-circular-progressbar/dist/styles.css';
2222

2323

24-
export default function IDE({ docId, modal, toggleModal, python, setpython, input, setInput, selected, setSelected, output, textEditor, setTextEditor, processing, percentageStage, isInputBoxShown }) {
24+
export default function IDE({ docId, modal, toggleModal, python, setpython, input, setInput, selected, setSelected, output, textEditor, setTextEditor, processing, percentageStage, isInputBoxShown, setOutput }) {
2525
const [socket, setSocket] = useState(null);
2626
const [cpp, setcpp] = useState('');
2727
const [java, setjava] = useState('');
@@ -64,6 +64,8 @@ export default function IDE({ docId, modal, toggleModal, python, setpython, inpu
6464
setcpp(data.cpp);
6565
setjava(data.java);
6666
setpython(data.python);
67+
setInput(data.input);
68+
setOutput(data.output);
6769
});
6870
// eslint-disable-next-line
6971
}, [socket, docId]);
@@ -75,22 +77,24 @@ export default function IDE({ docId, modal, toggleModal, python, setpython, inpu
7577
setpython(delta.python);
7678
setjava(delta.java);
7779
setcpp(delta.cpp);
78-
setcpp(delta.cpp);
79-
setcpp(delta.cpp);
80+
setInput(delta.input);
81+
setOutput(delta.output);
8082
}
8183
socket.on('receive-changes', updateC);
8284
return () => {
8385
socket.off('receive-changes', updateC);
8486
}
8587
// eslint-disable-next-line
86-
}, [socket, cpp, java, python]);
88+
}, [socket, cpp, java, python, input, output]);
8789

8890
useEffect(() => {
8991
if (socket === null) return;
9092
var data = {
9193
'cpp': cpp,
9294
'java': java,
93-
'python': python
95+
'python': python,
96+
'input': input,
97+
'output': output
9498
};
9599

96100
var savetodb = setTimeout(() => { socket.emit('save-document', data); socket.emit('changes', data); }, 2000);
@@ -99,7 +103,7 @@ export default function IDE({ docId, modal, toggleModal, python, setpython, inpu
99103
clearTimeout(savetodb);
100104
};
101105

102-
}, [socket, cpp, java, python]);
106+
}, [socket, cpp, java, python, input, output]);
103107

104108

105109
function addVideoStream(videoCont, video, stream) {

0 commit comments

Comments
 (0)