Skip to content

Commit

Permalink
Fix flicker and auto-compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Sep 1, 2023
1 parent 523176a commit 116c382
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 0 additions & 2 deletions components/LoadLFortran.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ function LoadLFortran({
lfortran_funcs,
openNotification,
myPrint,
handleUserTabChange
}) {

const { basePath } = useRouter();
Expand All @@ -179,7 +178,6 @@ function LoadLFortran({
setModuleReady(true);
openNotification("LFortran Module Initialized!", "bottomRight");
console.log("LFortran Module Initialized!");
handleUserTabChange("STDOUT");
}, [moduleReady]); // update the callback if the state changes

return (
Expand Down
7 changes: 5 additions & 2 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function Home() {
const [exampleName, setExampleName] = useState("main");
const [activeTab, setActiveTab] = useState("STDOUT");
const [output, setOutput] = useState("");
const [dataFetch, setDataFetch] = useState(false);
const isMobile = useIsMobile();

const myHeight = ((!isMobile) ? "calc(100vh - 170px)" : "calc(50vh - 85px)");
Expand All @@ -55,7 +56,7 @@ export default function Home() {

useEffect(() => {
if(moduleReady) { handleUserTabChange("STDOUT"); }
}, [moduleReady]);
}, [moduleReady, dataFetch]);

async function fetchData() {
const url = window.location.search;
Expand All @@ -64,12 +65,14 @@ export default function Home() {

if (urlParams.get("code")) {
setSourceCode(decodeURIComponent(urlParams.get("code")));
setDataFetch(true);
} else if (urlParams.get("gist")) {
const gistUrl = gist + urlParams.get("gist") + "/raw/";
fetch(gistUrl)
.then((response) => response.text())
.then((data) => {
setSourceCode(data);
setDataFetch(true);
openNotification(
"Source Code loaded from gist.",
"bottomRight"
Expand All @@ -81,6 +84,7 @@ export default function Home() {
});
} else {
setSourceCode(preinstalled_programs.basic.mandelbrot);
setDataFetch(true);
}
}

Expand Down Expand Up @@ -152,7 +156,6 @@ export default function Home() {
lfortran_funcs={lfortran_funcs}
openNotification={openNotification}
myPrint={setOutput}
handleUserTabChange={handleUserTabChange}
></LoadLFortran>

<Row gutter={[16, 16]}>
Expand Down

0 comments on commit 116c382

Please sign in to comment.