- End of list
+
+
+
+
+ Loading...
+
+
+ End of list
+
+
+ ERROR: {{ error }}
+
diff --git a/components/nav/NavSide.vue b/components/nav/NavSide.vue
index 3b7513ff..061c30ff 100644
--- a/components/nav/NavSide.vue
+++ b/components/nav/NavSide.vue
@@ -4,43 +4,37 @@
-
+
Home
-
+
Notifications
-
+
Explore
-
+
Local
-
+
Federated
-
+
- Direct Messages
+ Messages
-
+
Favorites
-
+
Bookmarks
-
-
diff --git a/components/notification/NotificationPaginator.client.vue b/components/notification/NotificationPaginator.client.vue
index 3dcce353..b539d0ca 100644
--- a/components/notification/NotificationPaginator.client.vue
+++ b/components/notification/NotificationPaginator.client.vue
@@ -4,15 +4,18 @@ import type { Notification, Paginator } from 'masto'
const { paginator } = defineProps<{
paginator: Paginator
}>()
-
-const { items: notifications, state, endAnchor } = usePaginator(paginator)
-
-
-
+
+
+
-
diff --git a/components/timeline/TimelinePaginator.client.vue b/components/timeline/TimelinePaginator.client.vue
index dc50598f..88bb5c47 100644
--- a/components/timeline/TimelinePaginator.client.vue
+++ b/components/timeline/TimelinePaginator.client.vue
@@ -4,15 +4,18 @@ import type { Paginator, Status } from 'masto'
const { paginator } = defineProps<{
paginator: Paginator
}>()
-
-const { items: statuses, state, endAnchor } = usePaginator(paginator)
-
-
-
+
+
+
-
diff --git a/composables/paginator.ts b/composables/paginator.ts
index 4c3055ed..a9c9ec11 100644
--- a/composables/paginator.ts
+++ b/composables/paginator.ts
@@ -2,23 +2,34 @@ import type { Paginator } from 'masto'
import type { PaginatorState } from '~/types'
export function usePaginator(paginator: Paginator) {
- let state = $ref('ready' as PaginatorState)
- const items = $ref([])
+ const state = ref('idle')
+ const items = ref([])
const endAnchor = ref()
const bound = reactive(useElementBounding(endAnchor))
const isInScreen = $computed(() => bound.top < window.innerHeight * 2)
+ const error = ref()
async function loadNext() {
- if (state === 'loading' || state === 'done')
+ if (state.value !== 'idle')
return
- state = 'loading'
- const result = await paginator.next()
- state = result.done ? 'done' : 'ready'
+ state.value = 'loading'
+ try {
+ const result = await paginator.next()
- if (result.value?.length)
- items.push(...result.value)
+ if (result.value?.length) {
+ items.value.push(...result.value)
+ state.value = 'idle'
+ }
+ else {
+ state.value = 'done'
+ }
+ }
+ catch (e) {
+ error.value = e
+ state.value = 'error'
+ }
await nextTick()
bound.update()
@@ -31,11 +42,16 @@ export function usePaginator(paginator: Paginator) {
watch(
() => isInScreen,
() => {
- if (isInScreen && state !== 'loading')
+ if (isInScreen && state.value === 'idle')
loadNext()
},
{ immediate: true },
)
- return { items, state, endAnchor }
+ return {
+ items,
+ state,
+ error,
+ endAnchor,
+ }
}
diff --git a/pages/public/index.vue b/pages/public/index.vue
index 5807f39c..afa9a0a2 100644
--- a/pages/public/index.vue
+++ b/pages/public/index.vue
@@ -1,6 +1,6 @@
@@ -12,7 +12,7 @@ const { data: timelines } = await useAsyncData('timelines-public', () => masto.t
-
+
diff --git a/types/index.ts b/types/index.ts
index 61485d41..f4d1d8af 100644
--- a/types/index.ts
+++ b/types/index.ts
@@ -16,4 +16,4 @@ export interface UserLogin {
account?: AccountCredentials
}
-export type PaginatorState = 'ready' | 'loading' | 'done'
+export type PaginatorState = 'idle' | 'loading' | 'done' | 'error'