fix(island): 🐛 replace old hard coded fetch endpoint
This commit is contained in:
parent
80ad700c4c
commit
759bb90e18
|
@ -20,7 +20,7 @@ export type CardListProps<ApiResponse, RefType = null> = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CardList<ApiResponse, RefType = null>(
|
export default function CardList<ApiResponse, RefType = null>(
|
||||||
{ limit, builder, ...props }: CardListProps<ApiResponse, RefType>,
|
{ limit, builder, apiRoute, ...props }: CardListProps<ApiResponse, RefType>,
|
||||||
) {
|
) {
|
||||||
const list: Signal<JSX.Element[]> = useSignal<JSX.Element[]>([])
|
const list: Signal<JSX.Element[]> = useSignal<JSX.Element[]>([])
|
||||||
const ac = new AbortController()
|
const ac = new AbortController()
|
||||||
|
@ -34,7 +34,7 @@ export default function CardList<ApiResponse, RefType = null>(
|
||||||
if (ref.current && useObserver) {
|
if (ref.current && useObserver) {
|
||||||
const observer = new IntersectionObserver(([entry]) => {
|
const observer = new IntersectionObserver(([entry]) => {
|
||||||
if (entry.isIntersecting) {
|
if (entry.isIntersecting) {
|
||||||
fillList(list, builder, { limit, ac })
|
fillList(list, builder, apiRoute, { limit, ac })
|
||||||
observer.disconnect()
|
observer.disconnect()
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
@ -42,7 +42,7 @@ export default function CardList<ApiResponse, RefType = null>(
|
||||||
})
|
})
|
||||||
observer.observe(ref.current)
|
observer.observe(ref.current)
|
||||||
} else {
|
} else {
|
||||||
fillList(list, builder, { limit, ac })
|
fillList(list, builder, apiRoute, { limit, ac })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -67,11 +67,12 @@ export default function CardList<ApiResponse, RefType = null>(
|
||||||
function fillList<ApiResponse>(
|
function fillList<ApiResponse>(
|
||||||
list: Signal<JSX.Element[]>,
|
list: Signal<JSX.Element[]>,
|
||||||
builder: Builder<ApiResponse>,
|
builder: Builder<ApiResponse>,
|
||||||
|
apiRoute: string,
|
||||||
{ limit, ac }: { limit?: number; ac?: AbortController },
|
{ limit, ac }: { limit?: number; ac?: AbortController },
|
||||||
) {
|
) {
|
||||||
;(async () => {
|
;(async () => {
|
||||||
const propsList = requestApiStream<void, ApiResponse>(
|
const propsList = requestApiStream<void, ApiResponse>(
|
||||||
'news/fetchAll',
|
apiRoute,
|
||||||
'GET',
|
'GET',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue