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!`}
</div>
)}
{results > 0 && <div>{`${results} találat.`}</div>}
{results > 0 && searchTerm ? <div>{`${results} találat.`}</div> : null}
</div>
)
}

View file

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

View file

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

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,
})
if (globalState.qdbs) {
setDbs(globalState.qdbs)
} else {
fetchDbs().then((res) => {
setDbs(res)
setGlobalState({
qdbs: res,
})
})
}
}, [])
useEffect(() => {

View file

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