feat: support muting conversations (#614)

This commit is contained in:
Daniel Roe 2022-12-28 22:44:23 +01:00 committed by GitHub
parent b6f0bd356a
commit f65f9c9a1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 37 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import type { Status } from 'masto'
type Action = 'reblogged' | 'favourited' | 'bookmarked' | 'pinned'
type Action = 'reblogged' | 'favourited' | 'bookmarked' | 'pinned' | 'muted'
type CountField = 'reblogsCount' | 'favouritesCount'
export interface StatusActionsProps {
@ -24,6 +24,7 @@ export function useStatusActions(props: StatusActionsProps) {
bookmarked: false,
pinned: false,
translation: false,
muted: false,
})
async function toggleStatusAction(action: Action, fetchNewStatus: () => Promise<Status>, countField?: CountField) {
@ -70,9 +71,15 @@ export function useStatusActions(props: StatusActionsProps) {
() => masto.statuses[status.pinned ? 'unpin' : 'pin'](status.id),
)
const toggleMute = async () => toggleStatusAction(
'muted',
() => masto.statuses[status.muted ? 'unmute' : 'mute'](status.id),
)
return {
status: $$(status),
isLoading: $$(isLoading),
toggleMute,
toggleReblog,
toggleFavourite,
toggleBookmark,