diff --git a/src/components/pages/view-post.js b/src/components/pages/view-post.js
index 1ac35d7..4d0c63b 100644
--- a/src/components/pages/view-post.js
+++ b/src/components/pages/view-post.js
@@ -21,6 +21,9 @@ const ViewPostJsx = ({navigation}) => {
afterDelete = {
() => navigation.goBack()
}
+ afterModerate = {
+ () => navigation.goBack()
+ }
data = { state.post } />
);
diff --git a/src/components/posts/post.js b/src/components/posts/post.js
index 7af3e23..857e517 100644
--- a/src/components/posts/post.js
+++ b/src/components/posts/post.js
@@ -118,13 +118,14 @@ export const RawPostJsx = (props) => {
>
: <>
-
>
}
@@ -311,7 +312,46 @@ export const PostByDataJsx = (props) => {
deleted: true,
});
}
- }
+ };
+
+ const _handleHide = async () => {
+ await requests.muteAccount(
+ state.instance,
+ state.data.account.id,
+ state.accessToken,
+
+ // Thus, only "mute" statuses
+ { notifications: false, }
+ );
+
+ if (props.afterModerate) {
+ props.afterModerate();
+ }
+ };
+
+ const _handleMute = async () => {
+ await requests.muteAccount(
+ state.instance,
+ state.data.account.id,
+ state.accessToken,
+ );
+
+ if (props.afterModerate) {
+ props.afterModerate();
+ }
+ };
+
+ const _handleBlock = async () => {
+ await requests.blockAccount(
+ state.instance,
+ state.data.account.id,
+ state.accessToken,
+ );
+
+ if (props.afterModerate) {
+ props.afterModerate();
+ }
+ };
return (
@@ -323,6 +363,9 @@ export const PostByDataJsx = (props) => {
onReblog = { _handleReblog }
onBookmark = { _handleDelete }
onDelete = { _handleDelete }
+ onHide = { _handleHide }
+ onMute = { _handleMute }
+ onBlock = { _handleBlock }
own = { state.own }
navigation = { props.navigation }/>
: }
diff --git a/src/requests.js b/src/requests.js
index fd66e5e..1582d49 100644
--- a/src/requests.js
+++ b/src/requests.js
@@ -39,11 +39,11 @@ export async function checkUnreadNotifications() {
}
}
-export async function postForm(url, data, token = false) {
+export async function postForm(url, data = false, token = false) {
// Send a POST request with data formatted with FormData returning JSON
const resp = await fetch(url, {
method: "POST",
- body: objectToForm(data),
+ body: data ? objectToForm(data): {},
headers: token
? { "Authorization": `Bearer ${token}`, }
: {},
@@ -103,6 +103,26 @@ export async function fetchAccountStatuses(domain, id, token) {
return resp.json();
}
+export async function muteAccount(domain, id, token, params = false) {
+ const resp = await postForm(`https://${domain}/api/v1/accounts/${id}/mute`, params, token);
+ return resp.json();
+}
+
+export async function unmuteAccount(domain, id, token) {
+ const resp = await post(`https://${domain}/api/v1/accounts/${id}/unmute`, token);
+ return resp.json();
+}
+
+export async function blockAccount(domain, id, token) {
+ const resp = await post(`https://${domain}/api/v1/accounts/${id}/block`, token);
+ return resp.json();
+}
+
+export async function unblockAccount(domain, id, token) {
+ const resp = await post(`https://${domain}/api/v1/accounts/${id}/unblock`, token);
+ return resp.json();
+}
+
export async function publishStatus(domain, token, params) {
const resp = await postForm(`https://${domain}/api/v1/statuses`, params, token);
return resp.json();