allquestions dbs cache fix, minor style changes

This commit is contained in:
mrfry 2021-06-09 11:22:28 +02:00
parent 14d8e43083
commit 1337bcdd1a
5 changed files with 15 additions and 10 deletions

View file

@ -57,7 +57,6 @@ function fetchAllData(dbs) {
function fetchDbs() {
return new Promise((resolve) => {
console.info('Fetching data')
fetch(`${constants.apiUrl}getDbs`, {
credentials: 'include',
})
@ -86,9 +85,16 @@ export default function AllQuestions({ router, globalState, setGlobalState }) {
router.replace(`${router.asPath.replace('.html', '')}`, undefined, {
shallow: true,
})
fetchDbs().then((res) => {
setDbs(res)
})
if (globalState.qdbs) {
setDbs(globalState.qdbs)
} else {
fetchDbs().then((res) => {
setDbs(res)
setGlobalState({
qdbs: res,
})
})
}
}, [])
useEffect(() => {