Skip to content

Commit 7f46354

Browse files
committed
fix: Handle error state in DetectBottom component
1 parent 48e3cb6 commit 7f46354

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Shared/Components/DetectBottom/DetectBottom.component.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616

1717
import { useEffect, useRef } from 'react'
1818
import { useIntersection } from '../../Helpers'
19+
import { GenericSectionErrorState } from '../GenericSectionErrorState'
1920

2021
interface DetectBottomProps {
2122
callback: () => void
23+
hasError?: boolean
2224
}
2325

24-
const DetectBottom = ({ callback }: DetectBottomProps) => {
26+
const DetectBottom = ({ callback, hasError }: DetectBottomProps) => {
2527
const target = useRef<HTMLSpanElement>(null)
2628
const intersected = useIntersection(target, {
2729
rootMargin: '0px',
@@ -34,6 +36,14 @@ const DetectBottom = ({ callback }: DetectBottomProps) => {
3436
}
3537
}, [intersected])
3638

39+
if (hasError) {
40+
return (
41+
<div className="p-24 flex">
42+
<GenericSectionErrorState reload={callback} />
43+
</div>
44+
)
45+
}
46+
3747
return <span className="pb-5" ref={target} />
3848
}
3949

src/Shared/Components/Plugin/PluginList.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ const PluginList = ({
2323
const { appId } = useParams<PluginListParamsType>()
2424

2525
const [isLoadingMorePlugins, setIsLoadingMorePlugins] = useState<boolean>(false)
26+
const [hasError, setHasError] = useState<boolean>(false)
27+
2628
const handleLoadMore = async () => {
2729
setIsLoadingMorePlugins(true)
30+
setHasError(false)
2831
try {
2932
const pluginDataResponse = await abortPreviousRequests(
3033
() =>
@@ -40,7 +43,7 @@ const PluginList = ({
4043

4144
handleDataUpdateForPluginResponse(pluginDataResponse, true)
4245
} catch (error) {
43-
// Do nothing
46+
setHasError(true)
4447
} finally {
4548
setIsLoadingMorePlugins(false)
4649
}
@@ -73,8 +76,9 @@ const PluginList = ({
7376

7477
{isLoadingMorePlugins && <PluginCardSkeletonList />}
7578

76-
{/* TODO: Handle on error */}
77-
{totalCount > pluginList.length && !isLoadingMorePlugins && <DetectBottom callback={handleLoadMore} />}
79+
{totalCount > pluginList.length && !isLoadingMorePlugins && (
80+
<DetectBottom callback={handleLoadMore} hasError={hasError} />
81+
)}
7882
</>
7983
)
8084
}

0 commit comments

Comments
 (0)