Skip to content

Commit a02566d

Browse files
committed
Revert "fix: new toots doesn't load anymore (#3429)"
This reverts commit 2b43e82. The masto.js major update caused several issues. ref. #3431
1 parent e521bad commit a02566d

File tree

10 files changed

+262
-384
lines changed

10 files changed

+262
-384
lines changed

app/components/timeline/TimelineHome.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ function reorderAndFilter(items: mastodon.v1.Status[]) {
1111
return reorderedTimeline(items, 'home')
1212
}
1313
14-
let followedTags: mastodon.v1.Tag[]
14+
let followedTags: mastodon.v1.Tag[] | undefined
1515
if (currentUser.value !== undefined) {
16-
const { client } = useMasto()
17-
const paginator = client.value.v1.followedTags.list()
18-
followedTags = (await paginator.values().next()).value ?? []
16+
followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
1917
}
2018
</script>
2119

app/components/timeline/TimelineNotifications.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ const options = { limit: 30, types: filter ? [filter] : [] }
1313
1414
// Default limit is 20 notifications, and servers are normally caped to 30
1515
const paginator = useMastoClient().v1.notifications.list(options)
16-
17-
// @ts-expect-error Type error should be fixed with the following PR to masto.js: https://github.com/neet/masto.js/pull/1355
1816
const stream = useStreaming(client => client.user.notification.subscribe())
1917
2018
lastAccessedNotificationRoute.value = route.path.replace(/\/notifications\/?/, '')

app/composables/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export async function fetchAccountByHandle(acct: string): Promise<mastodon.v1.Ac
7474
}
7575
else {
7676
const userAcctDomain = userAcct.includes('@') ? userAcct : `${userAcct}@${domain}`
77-
account = (await client.v1.search.list({ q: `@${userAcctDomain}`, type: 'accounts' })).accounts[0]
77+
account = (await client.v1.search.fetch({ q: `@${userAcctDomain}`, type: 'accounts' })).accounts[0]
7878
}
7979

8080
if (account.acct && !account.acct.includes('@') && domain)

app/composables/masto/notification.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function useNotifications() {
4747
const paginator = client.value.v1.notifications.list({ limit: 30 })
4848

4949
do {
50-
const result = await paginator.values().next()
50+
const result = await paginator.next()
5151
if (!result.done && result.value.length) {
5252
for (const notification of result.value) {
5353
if (notification.id === position.notifications.lastReadId)

app/composables/masto/search.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function useSearch(query: MaybeRefOrGetter<string>, options: UseSearchOpt
7777
...resolveUnref(options),
7878
resolve: !!currentUser.value,
7979
})
80-
const nextResults = await paginator.values().next()
80+
const nextResults = await paginator.next()
8181

8282
done.value = !!nextResults.done
8383
if (!nextResults.done)
@@ -91,7 +91,7 @@ export function useSearch(query: MaybeRefOrGetter<string>, options: UseSearchOpt
9191
return
9292

9393
loading.value = true
94-
const nextResults = await paginator.values().next()
94+
const nextResults = await paginator.next()
9595
loading.value = false
9696

9797
done.value = !!nextResults.done

app/composables/paginator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { mastodon } from 'masto'
33
import type { Ref } from 'vue'
44

55
export function usePaginator<T, P, U = T>(
6-
paginator: mastodon.Paginator<T[], P>,
6+
_paginator: mastodon.Paginator<T[], P>,
77
stream: Ref<mastodon.streaming.Subscription | undefined>,
88
eventType: 'update' | 'notification' = 'update',
99
preprocess: (items: (T | U)[]) => U[] = items => items as unknown as U[],
@@ -12,6 +12,7 @@ export function usePaginator<T, P, U = T>(
1212
// called `next` method will mutate the internal state of the variable,
1313
// and we need its initial state after HMR
1414
// so clone it
15+
const paginator = _paginator.clone()
1516

1617
const state = ref<PaginatorState>(isHydrated.value ? 'idle' : 'loading')
1718
const items = ref<U[]>([])
@@ -74,7 +75,7 @@ export function usePaginator<T, P, U = T>(
7475

7576
state.value = 'loading'
7677
try {
77-
const result = await paginator.values().next()
78+
const result = await paginator.next()
7879

7980
if (!result.done && result.value.length) {
8081
const preprocessedItems = preprocess([...nextItems.value, ...result.value] as (U | T)[])

app/composables/tiptap/suggestion.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const TiptapMentionSuggestion: Partial<SuggestionOptions> = import.meta.s
2828
return []
2929

3030
const paginator = useMastoClient().v2.search.list({ q: query, type: 'accounts', limit: 25, resolve: true })
31-
return (await paginator.values().next()).value?.accounts ?? []
31+
return (await paginator.next()).value?.accounts ?? []
3232
},
3333
render: createSuggestionRenderer(TiptapMentionList),
3434
}
@@ -47,7 +47,7 @@ export const TiptapHashtagSuggestion: Partial<SuggestionOptions> = {
4747
resolve: false,
4848
excludeUnreviewed: true,
4949
})
50-
return (await paginator.values().next()).value?.hashtags ?? []
50+
return (await paginator.next()).value?.hashtags ?? []
5151
},
5252
render: createSuggestionRenderer(TiptapHashtagList),
5353
}

app/middleware/1.permalink.global.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
4444

4545
// If we're logged in, search for the local id the account or status corresponds to
4646
const paginator = masto.client.value.v2.search.list({ q: `https:/${to.fullPath}`, resolve: true, limit: 1 })
47-
const { accounts, statuses } = (await paginator.values().next()).value ?? { accounts: [], statuses: [] }
47+
const { accounts, statuses } = (await paginator.next()).value ?? { accounts: [], statuses: [] }
4848

4949
if (statuses[0])
5050
return getStatusRoute(statuses[0])

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"js-yaml": "^4.1.0",
9595
"lru-cache": "^11.0.0",
9696
"magic-string": "^0.30.19",
97-
"masto": "^7.5.0",
97+
"masto": "^6.10.4",
9898
"mocked-exports": "^0.1.1",
9999
"node-emoji": "^2.1.3",
100100
"nuxt": "^4.1.2",

0 commit comments

Comments
 (0)