Revert "fix: new toots doesn't load anymore (#3429)"

This reverts commit 2b43e82bd9.

The masto.js major update caused several issues. ref. https://github.com/elk-zone/elk/issues/3431
pull/3436/head
TAKAHASHI Shuuji 2025-11-23 01:39:30 +09:00
rodzic e521bad2d1
commit a02566d7ae
10 zmienionych plików z 262 dodań i 384 usunięć

Wyświetl plik

@ -11,11 +11,9 @@ function reorderAndFilter(items: mastodon.v1.Status[]) {
return reorderedTimeline(items, 'home')
}
let followedTags: mastodon.v1.Tag[]
let followedTags: mastodon.v1.Tag[] | undefined
if (currentUser.value !== undefined) {
const { client } = useMasto()
const paginator = client.value.v1.followedTags.list()
followedTags = (await paginator.values().next()).value ?? []
followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
}
</script>

Wyświetl plik

@ -13,8 +13,6 @@ const options = { limit: 30, types: filter ? [filter] : [] }
// Default limit is 20 notifications, and servers are normally caped to 30
const paginator = useMastoClient().v1.notifications.list(options)
// @ts-expect-error Type error should be fixed with the following PR to masto.js: https://github.com/neet/masto.js/pull/1355
const stream = useStreaming(client => client.user.notification.subscribe())
lastAccessedNotificationRoute.value = route.path.replace(/\/notifications\/?/, '')

Wyświetl plik

@ -74,7 +74,7 @@ export async function fetchAccountByHandle(acct: string): Promise<mastodon.v1.Ac
}
else {
const userAcctDomain = userAcct.includes('@') ? userAcct : `${userAcct}@${domain}`
account = (await client.v1.search.list({ q: `@${userAcctDomain}`, type: 'accounts' })).accounts[0]
account = (await client.v1.search.fetch({ q: `@${userAcctDomain}`, type: 'accounts' })).accounts[0]
}
if (account.acct && !account.acct.includes('@') && domain)

Wyświetl plik

@ -47,7 +47,7 @@ export function useNotifications() {
const paginator = client.value.v1.notifications.list({ limit: 30 })
do {
const result = await paginator.values().next()
const result = await paginator.next()
if (!result.done && result.value.length) {
for (const notification of result.value) {
if (notification.id === position.notifications.lastReadId)

Wyświetl plik

@ -77,7 +77,7 @@ export function useSearch(query: MaybeRefOrGetter<string>, options: UseSearchOpt
...resolveUnref(options),
resolve: !!currentUser.value,
})
const nextResults = await paginator.values().next()
const nextResults = await paginator.next()
done.value = !!nextResults.done
if (!nextResults.done)
@ -91,7 +91,7 @@ export function useSearch(query: MaybeRefOrGetter<string>, options: UseSearchOpt
return
loading.value = true
const nextResults = await paginator.values().next()
const nextResults = await paginator.next()
loading.value = false
done.value = !!nextResults.done

Wyświetl plik

@ -3,7 +3,7 @@ import type { mastodon } from 'masto'
import type { Ref } from 'vue'
export function usePaginator<T, P, U = T>(
paginator: mastodon.Paginator<T[], P>,
_paginator: mastodon.Paginator<T[], P>,
stream: Ref<mastodon.streaming.Subscription | undefined>,
eventType: 'update' | 'notification' = 'update',
preprocess: (items: (T | U)[]) => U[] = items => items as unknown as U[],
@ -12,6 +12,7 @@ export function usePaginator<T, P, U = T>(
// called `next` method will mutate the internal state of the variable,
// and we need its initial state after HMR
// so clone it
const paginator = _paginator.clone()
const state = ref<PaginatorState>(isHydrated.value ? 'idle' : 'loading')
const items = ref<U[]>([])
@ -74,7 +75,7 @@ export function usePaginator<T, P, U = T>(
state.value = 'loading'
try {
const result = await paginator.values().next()
const result = await paginator.next()
if (!result.done && result.value.length) {
const preprocessedItems = preprocess([...nextItems.value, ...result.value] as (U | T)[])

Wyświetl plik

@ -28,7 +28,7 @@ export const TiptapMentionSuggestion: Partial<SuggestionOptions> = import.meta.s
return []
const paginator = useMastoClient().v2.search.list({ q: query, type: 'accounts', limit: 25, resolve: true })
return (await paginator.values().next()).value?.accounts ?? []
return (await paginator.next()).value?.accounts ?? []
},
render: createSuggestionRenderer(TiptapMentionList),
}
@ -47,7 +47,7 @@ export const TiptapHashtagSuggestion: Partial<SuggestionOptions> = {
resolve: false,
excludeUnreviewed: true,
})
return (await paginator.values().next()).value?.hashtags ?? []
return (await paginator.next()).value?.hashtags ?? []
},
render: createSuggestionRenderer(TiptapHashtagList),
}

Wyświetl plik

@ -44,7 +44,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
// If we're logged in, search for the local id the account or status corresponds to
const paginator = masto.client.value.v2.search.list({ q: `https:/${to.fullPath}`, resolve: true, limit: 1 })
const { accounts, statuses } = (await paginator.values().next()).value ?? { accounts: [], statuses: [] }
const { accounts, statuses } = (await paginator.next()).value ?? { accounts: [], statuses: [] }
if (statuses[0])
return getStatusRoute(statuses[0])

Wyświetl plik

@ -94,7 +94,7 @@
"js-yaml": "^4.1.0",
"lru-cache": "^11.0.0",
"magic-string": "^0.30.19",
"masto": "^7.5.0",
"masto": "^6.10.4",
"mocked-exports": "^0.1.1",
"node-emoji": "^2.1.3",
"nuxt": "^4.1.2",

Plik diff jest za duży Load Diff