chore: migrate to masto v7

This commit is contained in:
TAKAHASHI Shuuji 2025-05-21 13:53:36 +09:00
parent 8b0dca0a59
commit a586f9ffaf
7 changed files with 9 additions and 9 deletions

View file

@ -13,7 +13,7 @@ const options = { limit: 30, types: filter ? [filter] : [] }
// Default limit is 20 notifications, and servers are normally caped to 30 // Default limit is 20 notifications, and servers are normally caped to 30
const paginator = useMastoClient().v1.notifications.list(options) const paginator = useMastoClient().v1.notifications.list(options)
const stream = useStreaming(client => client.user.notification.subscribe()) const stream = useStreaming(client => client.user.subscribe())
lastAccessedNotificationRoute.value = route.path.replace(/\/notifications\/?/, '') lastAccessedNotificationRoute.value = route.path.replace(/\/notifications\/?/, '')

View file

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

View file

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

View file

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

View file

@ -12,7 +12,7 @@ export function usePaginator<T, P, U = T>(
// called `next` method will mutate the internal state of the variable, // called `next` method will mutate the internal state of the variable,
// and we need its initial state after HMR // and we need its initial state after HMR
// so clone it // so clone it
const paginator = _paginator.clone() const paginator = _paginator.values()
const state = ref<PaginatorState>(isHydrated.value ? 'idle' : 'loading') const state = ref<PaginatorState>(isHydrated.value ? 'idle' : 'loading')
const items = ref<U[]>([]) const items = ref<U[]>([])

View file

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

View file

@ -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 // 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 paginator = masto.client.value.v2.search.list({ q: `https:/${to.fullPath}`, resolve: true, limit: 1 })
const { accounts, statuses } = (await paginator.next()).value ?? { accounts: [], statuses: [] } const { accounts, statuses } = (await paginator.values().next()).value ?? { accounts: [], statuses: [] }
if (statuses[0]) if (statuses[0])
return getStatusRoute(statuses[0]) return getStatusRoute(statuses[0])