mirror of
https://github.com/elk-zone/elk.git
synced 2024-12-30 00:18:16 +03:00
fix: fix emoji reaction type error by extending Status type
This commit is contained in:
parent
abf1b05695
commit
fb4bc12b1d
1 changed files with 20 additions and 4 deletions
|
@ -3,12 +3,28 @@ import type { mastodon } from 'masto'
|
||||||
type Action = 'reblogged' | 'favourited' | 'bookmarked' | 'pinned' | 'muted'
|
type Action = 'reblogged' | 'favourited' | 'bookmarked' | 'pinned' | 'muted'
|
||||||
type CountField = 'reblogsCount' | 'favouritesCount'
|
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 {
|
export interface StatusActionsProps {
|
||||||
status: mastodon.v1.Status
|
status: Status
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useStatusActions(props: StatusActionsProps) {
|
export function useStatusActions(props: StatusActionsProps) {
|
||||||
const status = ref<mastodon.v1.Status>({ ...props.status })
|
const status = ref<Status>({ ...props.status })
|
||||||
const { client } = useMasto()
|
const { client } = useMasto()
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -27,7 +43,7 @@ export function useStatusActions(props: StatusActionsProps) {
|
||||||
muted: false,
|
muted: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
async function toggleStatusAction(action: Action, fetchNewStatus: () => Promise<mastodon.v1.Status>, countField?: CountField) {
|
async function toggleStatusAction(action: Action, fetchNewStatus: () => Promise<Status>, countField?: CountField) {
|
||||||
// check login
|
// check login
|
||||||
if (!checkLogin())
|
if (!checkLogin())
|
||||||
return
|
return
|
||||||
|
@ -63,7 +79,7 @@ export function useStatusActions(props: StatusActionsProps) {
|
||||||
'reblogged',
|
'reblogged',
|
||||||
() => client.value.v1.statuses.$select(status.value.id)[status.value.reblogged ? 'unreblog' : 'reblog']().then((res) => {
|
() => client.value.v1.statuses.$select(status.value.id)[status.value.reblogged ? 'unreblog' : 'reblog']().then((res) => {
|
||||||
if (status.value.reblogged)
|
if (status.value.reblogged)
|
||||||
// returns the original status
|
// returns the original status
|
||||||
return res.reblog!
|
return res.reblog!
|
||||||
return res
|
return res
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in a new issue