chore: migrate to new masto.js API
This commit is contained in:
parent
3919382302
commit
b0269c4366
5 changed files with 12 additions and 6 deletions
|
|
@ -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\/?/, '')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ export function useNotifications() {
|
||||||
processNotifications(stream, id)
|
processNotifications(stream, id)
|
||||||
|
|
||||||
const position = await client.value.v1.markers.fetch({ timeline: ['notifications'] })
|
const position = await client.value.v1.markers.fetch({ timeline: ['notifications'] })
|
||||||
const paginator = client.value.v1.notifications.list({ limit: 30 })
|
const paginator = client.value.v1.notifications.list({ limit: 30 }).values()
|
||||||
|
|
||||||
do {
|
do {
|
||||||
const result = await paginator.next()
|
const result = await paginator.next()
|
||||||
|
|
|
||||||
|
|
@ -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[]>([])
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import { currentCustomEmojis, updateCustomEmojis } from '~/composables/emojis'
|
||||||
export type { Emoji }
|
export type { Emoji }
|
||||||
|
|
||||||
export type CustomEmoji = (mastodon.v1.CustomEmoji & { custom: true })
|
export type CustomEmoji = (mastodon.v1.CustomEmoji & { custom: true })
|
||||||
|
|
||||||
export function isCustomEmoji(emoji: CustomEmoji | Emoji): emoji is CustomEmoji {
|
export function isCustomEmoji(emoji: CustomEmoji | Emoji): emoji is CustomEmoji {
|
||||||
return !!(emoji as CustomEmoji).custom
|
return !!(emoji as CustomEmoji).custom
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +28,12 @@ export const TiptapMentionSuggestion: Partial<SuggestionOptions> = import.meta.s
|
||||||
if (query.length === 0)
|
if (query.length === 0)
|
||||||
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,
|
||||||
|
}).values()
|
||||||
return (await paginator.next()).value?.accounts ?? []
|
return (await paginator.next()).value?.accounts ?? []
|
||||||
},
|
},
|
||||||
render: createSuggestionRenderer(TiptapMentionList),
|
render: createSuggestionRenderer(TiptapMentionList),
|
||||||
|
|
@ -46,7 +52,7 @@ export const TiptapHashtagSuggestion: Partial<SuggestionOptions> = {
|
||||||
limit: 25,
|
limit: 25,
|
||||||
resolve: false,
|
resolve: false,
|
||||||
excludeUnreviewed: true,
|
excludeUnreviewed: true,
|
||||||
})
|
}).values()
|
||||||
return (await paginator.next()).value?.hashtags ?? []
|
return (await paginator.next()).value?.hashtags ?? []
|
||||||
},
|
},
|
||||||
render: createSuggestionRenderer(TiptapHashtagList),
|
render: createSuggestionRenderer(TiptapHashtagList),
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,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 }).values()
|
||||||
const { accounts, statuses } = (await paginator.next()).value ?? { accounts: [], statuses: [] }
|
const { accounts, statuses } = (await paginator.next()).value ?? { accounts: [], statuses: [] }
|
||||||
|
|
||||||
if (statuses[0])
|
if (statuses[0])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue