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:
parent
0b9b5e301a
commit
d9ea43c9b4
3 changed files with 16 additions and 13 deletions
|
@ -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}>
|
||||
|
|
|
@ -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}>
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue