From c6c39d2ee42c291eb6aa5cbdc09580dab0d77cd5 Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Fri, 28 Apr 2023 17:50:27 +0200 Subject: [PATCH] Mute/Unmute controls on profiles --- src/api/relationships.ts | 35 +++++++++++++++++++++++++++++++++++ src/views/Profile.vue | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/src/api/relationships.ts b/src/api/relationships.ts index 37b62a3..b2063ea 100644 --- a/src/api/relationships.ts +++ b/src/api/relationships.ts @@ -11,6 +11,7 @@ export interface Relationship { subscription_from: boolean, showing_reblogs: boolean, showing_replies: boolean, + muting: boolean, } export async function follow( @@ -70,6 +71,40 @@ export async function unfollow( } } +export async function mute( + authToken: string, + accountId: string, +): Promise { + const url = `${BACKEND_URL}/api/v1/accounts/${accountId}/mute` + const response = await http(url, { + method: "POST", + authToken, + }) + const data = await response.json() + if (response.status !== 200) { + throw new Error(data.error_description) + } else { + return data + } +} + +export async function unmute( + authToken: string, + accountId: string, +): Promise { + const url = `${BACKEND_URL}/api/v1/accounts/${accountId}/unmute` + const response = await http(url, { + method: "POST", + authToken, + }) + const data = await response.json() + if (response.status !== 200) { + throw new Error(data.error_description) + } else { + return data + } +} + interface ProfileListPage { profiles: Profile[]; nextPageUrl: string | null; diff --git a/src/views/Profile.vue b/src/views/Profile.vue index a9c2887..cd535cd 100644 --- a/src/views/Profile.vue +++ b/src/views/Profile.vue @@ -27,6 +27,7 @@
Follows you
Subscription
Subscriber
+
Muted
+
  • + +
  • +
  • + +