initial null fix
This commit is contained in:
parent
b79120c7f7
commit
26f303140a
|
@ -57,7 +57,7 @@ export const SearchModal = () => {
|
||||||
const [isLoading, setIsLoading] = createSignal(false)
|
const [isLoading, setIsLoading] = createSignal(false)
|
||||||
const [offset, setOffset] = createSignal<number>(0)
|
const [offset, setOffset] = createSignal<number>(0)
|
||||||
const [searchResultsList, { refetch: loadSearchResults, mutate: setSearchResultsList }] = createResource<
|
const [searchResultsList, { refetch: loadSearchResults, mutate: setSearchResultsList }] = createResource<
|
||||||
Shout[]
|
Shout[] | null
|
||||||
>(
|
>(
|
||||||
async () => {
|
async () => {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
|
@ -73,7 +73,7 @@ export const SearchModal = () => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ssrLoadFrom: 'initial',
|
ssrLoadFrom: 'initial',
|
||||||
initialValue: [],
|
initialValue: null,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ export const SearchModal = () => {
|
||||||
await debouncedLoadMore()
|
await debouncedLoadMore()
|
||||||
} else {
|
} else {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
setSearchResultsList([])
|
setSearchResultsList(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,14 +96,14 @@ export const SearchModal = () => {
|
||||||
await debouncedLoadMore()
|
await debouncedLoadMore()
|
||||||
} else {
|
} else {
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
setSearchResultsList([])
|
setSearchResultsList(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup the debounce timer when the component unmounts
|
// Cleanup the debounce timer when the component unmounts
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
debouncedLoadMore.cancel()
|
debouncedLoadMore.cancel()
|
||||||
console.log('cleanup search')
|
// console.debug('[SearchModal] cleanup debouncing search')
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -156,7 +156,7 @@ export const SearchModal = () => {
|
||||||
</Show>
|
</Show>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Show when={!searchResultsList()}>
|
<Show when={Array.isArray(searchResultsList()) && searchResultsList().length === 0}>
|
||||||
<p class={styles.searchDescription} innerHTML={t("We couldn't find anything for your request")} />
|
<p class={styles.searchDescription} innerHTML={t("We couldn't find anything for your request")} />
|
||||||
</Show>
|
</Show>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user