diff --git a/components/dashboard/links/Index.vue b/components/dashboard/links/Index.vue index 6b69fa9..cebaad8 100644 --- a/components/dashboard/links/Index.vue +++ b/components/dashboard/links/Index.vue @@ -6,23 +6,37 @@ const links = ref([]) const limit = 24 let cursor = '' let listComplete = false +let listError = false async function getLinks() { - const data = await useAPI('/api/link/list', { - query: { - limit, - cursor, - }, - }) - links.value = links.value.concat(data.links).filter(Boolean) // Sometimes cloudflare will return null, filter out - cursor = data.cursor - listComplete = data.list_complete + try { + const data = await useAPI('/api/link/list', { + query: { + limit, + cursor, + }, + }) + links.value = links.value.concat(data.links).filter(Boolean) // Sometimes cloudflare will return null, filter out + cursor = data.cursor + listComplete = data.list_complete + listError = false + } + catch (error) { + console.error(error) + listError = true + } } const { isLoading } = useInfiniteScroll( document, getLinks, - { distance: 150, interval: 1000, canLoadMore: () => !listComplete }, + { + distance: 150, + interval: 1000, + canLoadMore: () => { + return !listError && !listComplete + }, + }, ) function updateLinkList(link, type) { @@ -68,5 +82,14 @@ function updateLinkList(link, type) { > No more +