From 6c5bb83ac32aecb5868a0e47ed9bcd2195a9d706 Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 9 Jan 2024 09:56:15 +0100 Subject: [PATCH] feat: upgrade to masto.js v6 (#2530) --- components/account/AccountFollowButton.vue | 4 +- .../account/AccountFollowRequestButton.vue | 4 +- components/account/AccountHeader.vue | 4 +- components/account/AccountMoreButton.vue | 4 +- components/account/AccountPaginator.vue | 4 +- components/common/CommonPaginator.vue | 6 +- .../conversation/ConversationPaginator.vue | 4 +- components/list/Account.vue | 4 +- components/list/ListEntry.vue | 4 +- components/list/Lists.vue | 6 +- components/notification/NotificationCard.vue | 2 - .../notification/NotificationPaginator.vue | 6 +- components/publish/PublishWidget.vue | 5 +- components/report/ReportModal.vue | 6 +- .../settings/SettingsProfileMetadata.vue | 2 +- components/status/StatusActionsMore.vue | 4 +- .../status/StatusFavouritedBoostedBy.vue | 2 +- components/status/StatusPoll.vue | 2 +- components/status/edit/StatusEditHistory.vue | 2 +- components/tag/TagActionButton.vue | 4 +- components/tag/TagCardPaginator.vue | 4 +- components/timeline/TimelineDomainBlocks.vue | 2 +- components/timeline/TimelineHome.vue | 4 +- components/timeline/TimelineNotifications.vue | 2 +- components/timeline/TimelinePaginator.vue | 6 +- components/timeline/TimelinePinned.vue | 2 +- components/timeline/TimelinePublic.vue | 4 +- components/timeline/TimelinePublicLocal.vue | 4 +- composables/cache.ts | 6 +- composables/masto/masto.ts | 69 ++++----- composables/masto/notification.ts | 33 +++-- composables/masto/publish.ts | 11 +- composables/masto/relationship.ts | 12 +- composables/masto/search.ts | 8 +- composables/masto/status.ts | 10 +- composables/masto/statusDrafts.ts | 2 +- composables/paginator.ts | 35 +++-- .../createPushSubscription.ts | 10 +- composables/push-notifications/types.ts | 4 +- .../push-notifications/usePushManager.ts | 8 +- composables/tiptap/suggestion.ts | 8 +- composables/users.ts | 12 +- middleware/1.permalink.global.ts | 4 +- package.json | 6 +- pages/[[server]]/@[account]/[status].vue | 2 +- .../[[server]]/@[account]/index/followers.vue | 2 +- .../[[server]]/@[account]/index/following.vue | 2 +- pages/[[server]]/@[account]/index/index.vue | 2 +- pages/[[server]]/@[account]/index/media.vue | 2 +- .../@[account]/index/with_replies.vue | 2 +- pages/[[server]]/explore/index.vue | 2 +- pages/[[server]]/explore/links.vue | 2 +- pages/[[server]]/explore/tags.vue | 2 +- pages/[[server]]/list/[list]/index.vue | 2 +- .../[[server]]/list/[list]/index/accounts.vue | 2 +- pages/[[server]]/list/[list]/index/index.vue | 4 +- pages/[[server]]/tags/[tag].vue | 6 +- pages/settings/profile/appearance.vue | 2 +- pnpm-lock.yaml | 131 ++++++++---------- tests/setup.ts | 8 ++ types/index.ts | 2 +- vitest.config.ts | 5 + 62 files changed, 262 insertions(+), 263 deletions(-) create mode 100644 tests/setup.ts diff --git a/components/account/AccountFollowButton.vue b/components/account/AccountFollowButton.vue index bb7cc240..36916a7d 100644 --- a/components/account/AccountFollowButton.vue +++ b/components/account/AccountFollowButton.vue @@ -19,7 +19,7 @@ const { client } = $(useMasto()) async function unblock() { relationship!.blocking = false try { - const newRel = await client.v1.accounts.unblock(account.id) + const newRel = await client.v1.accounts.$select(account.id).unblock() Object.assign(relationship!, newRel) } catch (err) { @@ -32,7 +32,7 @@ async function unblock() { async function unmute() { relationship!.muting = false try { - const newRel = await client.v1.accounts.unmute(account.id) + const newRel = await client.v1.accounts.$select(account.id).unmute() Object.assign(relationship!, newRel) } catch (err) { diff --git a/components/account/AccountFollowRequestButton.vue b/components/account/AccountFollowRequestButton.vue index 61cab918..2c60a760 100644 --- a/components/account/AccountFollowRequestButton.vue +++ b/components/account/AccountFollowRequestButton.vue @@ -12,7 +12,7 @@ async function authorizeFollowRequest() { relationship!.requestedBy = false relationship!.followedBy = true try { - const newRel = await client.v1.followRequests.authorize(account.id) + const newRel = await client.v1.followRequests.$select(account.id).authorize() Object.assign(relationship!, newRel) } catch (err) { @@ -25,7 +25,7 @@ async function authorizeFollowRequest() { async function rejectFollowRequest() { relationship!.requestedBy = false try { - const newRel = await client.v1.followRequests.reject(account.id) + const newRel = await client.v1.followRequests.$select(account.id).reject() Object.assign(relationship!, newRel) } catch (err) { diff --git a/components/account/AccountHeader.vue b/components/account/AccountHeader.vue index 85d2cfe5..c97cf369 100644 --- a/components/account/AccountHeader.vue +++ b/components/account/AccountHeader.vue @@ -53,7 +53,7 @@ function previewAvatar() { async function toggleNotifications() { relationship!.notifying = !relationship?.notifying try { - const newRel = await client.v1.accounts.follow(account.id, { notify: relationship?.notifying }) + const newRel = await client.v1.accounts.$select(account.id).follow({ notify: relationship?.notifying }) Object.assign(relationship!, newRel) } catch { @@ -97,7 +97,7 @@ async function editNote(event: Event) { if (relationship.note?.trim() === newNote.trim()) return - const newNoteApiResult = await client.v1.accounts.createNote(account.id, { comment: newNote }) + const newNoteApiResult = await client.v1.accounts.$select(account.id).note.create({ comment: newNote }) relationship.note = newNoteApiResult.note personalNoteDraft.value = relationship.note ?? '' } diff --git a/components/account/AccountMoreButton.vue b/components/account/AccountMoreButton.vue index 5c524e9a..3a179fa2 100644 --- a/components/account/AccountMoreButton.vue +++ b/components/account/AccountMoreButton.vue @@ -33,7 +33,7 @@ async function toggleReblogs() { return const showingReblogs = !relationship?.showingReblogs - relationship = await client.v1.accounts.follow(account.id, { reblogs: showingReblogs }) + relationship = await client.v1.accounts.$select(account.id).follow({ reblogs: showingReblogs }) } async function addUserNote() { @@ -44,7 +44,7 @@ async function removeUserNote() { if (!relationship!.note || relationship!.note.length === 0) return - const newNote = await client.v1.accounts.createNote(account.id, { comment: '' }) + const newNote = await client.v1.accounts.$select(account.id).note.create({ comment: '' }) relationship!.note = newNote.note emit('removeNote') } diff --git a/components/account/AccountPaginator.vue b/components/account/AccountPaginator.vue index 86bcccb8..0445439d 100644 --- a/components/account/AccountPaginator.vue +++ b/components/account/AccountPaginator.vue @@ -1,8 +1,8 @@ diff --git a/components/timeline/TimelineDomainBlocks.vue b/components/timeline/TimelineDomainBlocks.vue index 0763e8ec..a4dfcf20 100644 --- a/components/timeline/TimelineDomainBlocks.vue +++ b/components/timeline/TimelineDomainBlocks.vue @@ -3,7 +3,7 @@ const { client } = $(useMasto()) const paginator = client.v1.domainBlocks.list() async function unblock(domain: string) { - await client.v1.domainBlocks.unblock(domain) + await client.v1.domainBlocks.remove({ domain }) } diff --git a/components/timeline/TimelineHome.vue b/components/timeline/TimelineHome.vue index 95793794..905335d3 100644 --- a/components/timeline/TimelineHome.vue +++ b/components/timeline/TimelineHome.vue @@ -1,8 +1,8 @@