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

@ -52,7 +52,7 @@ export default function QuestionSearchResult({ data, searchTerm }) {
próbáld bővíteni a keresési feltételt!`} próbáld bővíteni a keresési feltételt!`}
</div> </div>
)} )}
{results > 0 && <div>{`${results} találat.`}</div>} {results > 0 && searchTerm ? <div>{`${results} találat.`}</div> : null}
</div> </div>
) )
} }

View file

@ -9,7 +9,6 @@ export default function DbSelector({ onDbSelect, closeClick, text, showAll }) {
const [qdbs, setQdbs] = useState(null) const [qdbs, setQdbs] = useState(null)
useEffect(() => { useEffect(() => {
console.info('Fetching dbs')
fetch(`${constants.apiUrl}getDbs`, { fetch(`${constants.apiUrl}getDbs`, {
credentials: 'include', credentials: 'include',
}) })

View file

@ -48,6 +48,7 @@
padding: 0px 8px; padding: 0px 8px;
margin: 0px 2px; margin: 0px 2px;
text-decoration: none; text-decoration: none;
transition: width 0.5s, height 0.5s, ease-in 0.2s;
} }
.topBarLinks > *:hover { .topBarLinks > *:hover {
@ -56,7 +57,7 @@
} }
.topBarLinks a.active { .topBarLinks a.active {
border: 0.5px solid var(--text-color); background-color: var(--hoover-color);
border-radius: 5px; border-radius: 5px;
} }
@ -111,7 +112,7 @@
margin: 5px 2px; margin: 5px 2px;
text-decoration: none; text-decoration: none;
color: var(--bright-color); color: var(--bright-color);
transition: width 0.5s, height 0.5s, ease-in 0.5s; transition: width 0.5s, height 0.5s, ease-in 0.2s;
cursor: pointer; cursor: pointer;
} }
@ -127,7 +128,7 @@
color: black; color: black;
font-weight: bold; font-weight: bold;
text-shadow: 2px 2px 8px black; text-shadow: 2px 2px 8px black;
transition: width 0.5s, height 0.5s, ease-out 0.5s; transition: width 0.5s, height 0.5s, ease-out 0.2s;
} }
.userStatus { .userStatus {

View file

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

View file

@ -50,7 +50,6 @@ function getSinceDate(keyword) {
async function getListFromServer(since) { async function getListFromServer(since) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
console.info('Fetching data')
let query = '' let query = ''
if (since && since !== 'all') { if (since && since !== 'all') {
query = `?since=${getTimeString(getSinceDate(since))}` query = `?since=${getTimeString(getSinceDate(since))}`