mirror of
https://github.com/harness/drone.git
synced 2025-05-17 01:20:13 +08:00
CODE-520: Stop fetching details when backend errors out
This commit is contained in:
parent
11bd10f455
commit
d3fbb94be0
@ -108,9 +108,9 @@ export function FolderContent({
|
|||||||
const scrollCallback = useCallback(
|
const scrollCallback = useCallback(
|
||||||
throttle(() => {
|
throttle(() => {
|
||||||
pathsChunks.forEach(pathsChunk => {
|
pathsChunks.forEach(pathsChunk => {
|
||||||
const { paths, loaded, loading } = pathsChunk
|
const { paths, loaded, loading, failed } = pathsChunk
|
||||||
|
|
||||||
if (!loaded && !loading) {
|
if (!loaded && !loading && !failed) {
|
||||||
for (let i = 0; i < paths.length; i++) {
|
for (let i = 0; i < paths.length; i++) {
|
||||||
const element = document.querySelector(`[data-resource-path="${paths[i]}"]`)
|
const element = document.querySelector(`[data-resource-path="${paths[i]}"]`)
|
||||||
|
|
||||||
@ -134,6 +134,7 @@ export function FolderContent({
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
pathsChunk.loaded = false
|
pathsChunk.loaded = false
|
||||||
pathsChunk.loading = false
|
pathsChunk.loading = false
|
||||||
|
pathsChunk.failed = true
|
||||||
setPathsChunks(pathsChunks.map(_chunk => (pathsChunk === _chunk ? pathsChunk : _chunk)))
|
setPathsChunks(pathsChunks.map(_chunk => (pathsChunk === _chunk ? pathsChunk : _chunk)))
|
||||||
console.log('Failed to fetch path commit details', error) // eslint-disable-line no-console
|
console.log('Failed to fetch path commit details', error) // eslint-disable-line no-console
|
||||||
})
|
})
|
||||||
@ -153,7 +154,8 @@ export function FolderContent({
|
|||||||
chunk(resourceEntries.map(entry => entry.path as string) || [], LIST_FETCHING_LIMIT).map(paths => ({
|
chunk(resourceEntries.map(entry => entry.path as string) || [], LIST_FETCHING_LIMIT).map(paths => ({
|
||||||
paths,
|
paths,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
loading: false
|
loading: false,
|
||||||
|
failed: false
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
}, [resourceEntries])
|
}, [resourceEntries])
|
||||||
@ -207,8 +209,16 @@ function isInViewport(element: Element) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PathDetails {
|
type PathDetails = {
|
||||||
details: Array<{ path: string; last_commit: TypesCommit }>
|
details: Array<{
|
||||||
|
path: string
|
||||||
|
last_commit: TypesCommit
|
||||||
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
type PathsChunks = Array<{ paths: string[]; loaded: boolean; loading: boolean }>
|
type PathsChunks = Array<{
|
||||||
|
paths: string[]
|
||||||
|
loaded: boolean
|
||||||
|
loading: boolean
|
||||||
|
failed: boolean
|
||||||
|
}>
|
||||||
|
Loading…
Reference in New Issue
Block a user