1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 04:54:18 +00:00

🐛 Fix box repositories being stuck in loading

This commit is contained in:
Stefano Pigozzi 2021-05-10 14:13:12 +02:00
parent 0b9b5e301a
commit d9ea43c9b4
Signed by untrusted user who does not match committer: steffo
GPG key ID: 6965406171929D01
3 changed files with 16 additions and 13 deletions

View file

@ -18,18 +18,15 @@ import useDataImmediately from "../../hooks/useDataImmediately"
*/
export default function BoxRepositoriesActive({ ...props }) {
const {user, fetchDataAuth} = useContext(ContextUser)
const {data, started, loading, error} = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/", {
const {data, error, loading, fetchNow} = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/", {
"onlyActive": true,
})
let contents;
if(!started || loading) {
contents = <Loading/>
}
else if(error) {
if(error) {
contents = <BoxAlert color={"Red"}>{error.toString()}</BoxAlert>
}
else {
else if(data) {
let repositories = [...data["owner"], ...data["spectator"]]
if(repositories.length > 0) {
contents = repositories.map(repo => (
@ -46,6 +43,9 @@ export default function BoxRepositoriesActive({ ...props }) {
contents = <i>There's nothing here.</i>
}
}
else {
contents = <Loading/>
}
return (
<BoxFull header={"Your active repositories"} {...props}>

View file

@ -22,13 +22,10 @@ export default function BoxRepositoriesArchived({ ...props }) {
})
let contents;
if(!started || loading) {
contents = <Loading/>
}
else if(error) {
if(error) {
contents = <BoxAlert color={"Red"}>{error.toString()}</BoxAlert>
}
else {
else if(data) {
let repositories = [...data["owner"], ...data["spectator"]]
if(repositories.length > 0) {
contents = repositories.map(repo => (
@ -45,6 +42,9 @@ export default function BoxRepositoriesArchived({ ...props }) {
contents = <i>There's nothing here.</i>
}
}
else {
contents = <Loading/>
}
return (
<BoxFull header={"Your archived repositories"} {...props}>

View file

@ -20,16 +20,19 @@ export default function useData(fetchData, method, path, body, init) {
*/
const load = useCallback(
async () => {
console.debug(`Trying to ${method} ${path}...`)
console.debug(`Loading ${method} ${path}...`)
setLoading(true)
console.debug(`Fetching ${method} ${path}...`)
try {
const _data = await fetchData(method, path, body, init)
console.debug(`Displaying data of ${method} ${path}: `, _data)
setData(_data)
} catch(e) {
console.debug(`Displaying error of ${method} ${path}: `, e)
setError(e)
} finally {
console.debug(`Stopping loading of ${method} ${path}...`)
setLoading(false)
}
},