Skip to content

Commit

Permalink
workshops
Browse files Browse the repository at this point in the history
  • Loading branch information
szweibel committed Nov 3, 2023
1 parent c7f952a commit 93c6bbe
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
18 changes: 1 addition & 17 deletions components/Hooks/UseWorkshop.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
import useSWRImmutable from "swr/immutable";
import { useSWRConfig } from "swr";
import { useState, useEffect } from "react";
import { GitHub } from "@mui/icons-material";

export default function useWorkshop(gitUser, gitFile, builtURL, editing) {

let headers;
const [shouldFetch, setShouldFetch] = useState(false);
const [cacheCleared, setCacheCleared] = useState(false);
const { cache, mutate } = useSWRConfig()
const clearCache = () => {
cache.clear()
}

useEffect(() => {
if (editing == 'true' && cacheCleared == false) {
localStorage.removeItem('app-cache');
localStorage.removeItem('app-cache-time');
clearCache()
setCacheCleared(true)
console.log('cache cleared')
}
}, [editing])


if (process.env.NEXT_PUBLIC_GITHUBSECRET !== 'false') {
headers = new Headers(
{
Expand Down
2 changes: 1 addition & 1 deletion components/WorkshopsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function WorkshopsView({ gitUser, gitRepo, instUser, instRepo })
if (workshops[v] && workshops[v].type != 'dir' && workshops[v].name != 'README.md') {
return (
<div key={v}>
{gitUser && gitRepo &&
{
<UseWorkshopsComponent workshop={workshops[v]} gitUser={gitUser}
gitRepo={gitRepo} instRepo={instRepo} instUser={instUser} />
}
Expand Down
16 changes: 15 additions & 1 deletion pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import PyodideProvider from '../components/Wasm/PyodideProvider';
import { SWRConfig } from 'swr';
import { useRef } from 'react';
import NextNProgress from 'nextjs-progressbar';
import { useSWRConfig } from "swr";
import { useRouter } from 'next/router';


function MyApp({ Component, pageProps }) {

const [title, setTitle] = useState('');
Expand All @@ -23,7 +23,12 @@ function MyApp({ Component, pageProps }) {
const [gitRepo, setGitRepo] = useState(null);
const [instGitUser, setInstGitUser] = useState(null);
const [instGitRepo, setInstGitRepo] = useState(null);
const [cacheCleared, setCacheCleared] = useState(false);
const { cache, mutate } = useSWRConfig()
const router = useRouter();
const clearCache = () => {
cache.clear()
}


useEffect(() => {
Expand All @@ -35,6 +40,15 @@ function MyApp({ Component, pageProps }) {
if (router.pathname === '/inst' && urlParams.get('user') && urlParams.get('repo')) {
router.push('/inst?instUser=' + urlParams.get('user') + '&instRepo=' + urlParams.get('repo'))
}
if (urlParams.get('edit') === 'true') {
if (cacheCleared == false) {
localStorage.removeItem('app-cache');
localStorage.removeItem('app-cache-time');
clearCache()
setCacheCleared(true)
console.log('cache cleared')
}
}
}, [router])

pageProps.title = title
Expand Down
2 changes: 1 addition & 1 deletion pages/inst/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default function Institute(props) {
</div>
<div className='inst-workshops'>
<h1>Workshops</h1>
{props.gitUser && props.gitRepo && parsedYAML &&
{parsedYAML &&
<WorkshopsView gitUser={props.gitUser} gitRepo={props.gitRepo} instUser={props.instGitUser} instRepo={props.instGitRepo} />
}
</div>
Expand Down
3 changes: 1 addition & 2 deletions styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -984,12 +984,11 @@ nav.sidenav {
}

// Glossary
.glossary{
.glossary {
flex-grow: 1;
}

// Forms

.form {
width: 100%;

Expand Down

0 comments on commit 93c6bbe

Please sign in to comment.