From fb4bc12b1d5138c1919222a74ea0d9821cf7f519 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Thu, 19 Dec 2024 22:28:52 +0900 Subject: [PATCH] fix: fix emoji reaction type error by extending Status type --- composables/masto/status.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/composables/masto/status.ts b/composables/masto/status.ts index a2fa96b8..2662eae2 100644 --- a/composables/masto/status.ts +++ b/composables/masto/status.ts @@ -3,12 +3,28 @@ import type { mastodon } from 'masto' type Action = 'reblogged' | 'favourited' | 'bookmarked' | 'pinned' | 'muted' type CountField = 'reblogsCount' | 'favouritesCount' +// Add EmojiReaction type to support fedibird non-mastodon emoji reaction +export interface EmojiReaction { + name: string + count: number + accountIds: string[] + me: boolean + // Only used by custom emoji + url?: string + staticUrl?: string + domain?: string | null + width?: number + height?: number +} + +export type Status = mastodon.v1.Status & { emojiReactionsCount?: number, emojiReactions?: EmojiReaction[] } + export interface StatusActionsProps { - status: mastodon.v1.Status + status: Status } export function useStatusActions(props: StatusActionsProps) { - const status = ref({ ...props.status }) + const status = ref({ ...props.status }) const { client } = useMasto() watch( @@ -27,7 +43,7 @@ export function useStatusActions(props: StatusActionsProps) { muted: false, }) - async function toggleStatusAction(action: Action, fetchNewStatus: () => Promise, countField?: CountField) { + async function toggleStatusAction(action: Action, fetchNewStatus: () => Promise, countField?: CountField) { // check login if (!checkLogin()) return @@ -63,7 +79,7 @@ export function useStatusActions(props: StatusActionsProps) { 'reblogged', () => client.value.v1.statuses.$select(status.value.id)[status.value.reblogged ? 'unreblog' : 'reblog']().then((res) => { if (status.value.reblogged) - // returns the original status + // returns the original status return res.reblog! return res }),