Enable hiding content, muting and blocking
See #24 for why this works conceptually but doesn't do anything in practice
This commit is contained in:
parent
1afe0aadb4
commit
355782ff66
|
@ -21,6 +21,9 @@ const ViewPostJsx = ({navigation}) => {
|
|||
afterDelete = {
|
||||
() => navigation.goBack()
|
||||
}
|
||||
afterModerate = {
|
||||
() => navigation.goBack()
|
||||
}
|
||||
data = { state.post } />
|
||||
</ScreenWithBackBarJsx>
|
||||
);
|
||||
|
|
|
@ -118,13 +118,14 @@ export const RawPostJsx = (props) => {
|
|||
</>
|
||||
: <>
|
||||
<MenuOption
|
||||
onSelect = { props.onHide }
|
||||
text = "Don't show me their posts"/>
|
||||
<MenuOption
|
||||
onSelect = { props.onMute }
|
||||
text = "Mute" />
|
||||
<MenuOption
|
||||
onSelect = { props.onBlock }
|
||||
text = "Block" />
|
||||
<MenuOption
|
||||
text = "Report" />
|
||||
</>
|
||||
}
|
||||
</ContextMenuJsx>
|
||||
|
@ -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 (
|
||||
<View>
|
||||
|
@ -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 }/>
|
||||
: <View></View> }
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue