From cd490fffec8aeb4e34906fed28e901efb365302c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Fri, 13 Jan 2023 00:21:27 +0800 Subject: [PATCH] fix: fetch the first page of data --- composables/tiptap/suggestion.ts | 12 ++++-------- middleware/permalink.global.ts | 4 +--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/composables/tiptap/suggestion.ts b/composables/tiptap/suggestion.ts index 4f185540..209428f6 100644 --- a/composables/tiptap/suggestion.ts +++ b/composables/tiptap/suggestion.ts @@ -14,10 +14,8 @@ export const MentionSuggestion: Partial = { if (query.length === 0) return [] - const mentionPaginator = useMasto().v2.search({ q: query, type: 'accounts', limit: 25, resolve: true }) - const results = await mentionPaginator.next() - - return results.value.accounts + const results = await useMasto().v2.search({ q: query, type: 'accounts', limit: 25, resolve: true }) + return results.accounts }, render: createSuggestionRenderer(TiptapMentionList), } @@ -29,16 +27,14 @@ export const HashtagSuggestion: Partial = { if (query.length === 0) return [] - const paginator = useMasto().v2.search({ + const results = await useMasto().v2.search({ q: query, type: 'hashtags', limit: 25, resolve: false, excludeUnreviewed: true, }) - const results = await paginator.next() - - return results.value.hashtags + return results.hashtags }, render: createSuggestionRenderer(TiptapHashtagList), } diff --git a/middleware/permalink.global.ts b/middleware/permalink.global.ts index d4b9b0ef..2a1b0eb5 100644 --- a/middleware/permalink.global.ts +++ b/middleware/permalink.global.ts @@ -53,9 +53,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => { await masto.loginTo(currentUser.value) // If we're logged in, search for the local id the account or status corresponds to - const { value } = await masto.v2.search({ q: `https:/${to.fullPath}`, resolve: true, limit: 1 }).next() - - const { accounts, statuses } = value + const { accounts, statuses } = await masto.v2.search({ q: `https:/${to.fullPath}`, resolve: true, limit: 1 }) if (statuses[0]) return getStatusRoute(statuses[0])