Enable hiding, muting and blocking from ViewProfile

This commit is contained in:
Nat 2021-05-22 21:36:31 -03:00
parent 355782ff66
commit 19c9629197
2 changed files with 53 additions and 5 deletions

View File

@ -37,7 +37,7 @@ const ContextMenuJsx = (props) => {
<FontAwesome <FontAwesome
name = "ellipsis-h" name = "ellipsis-h"
size = { props.size ? props.size : 24 } size = { props.size ? props.size : 24 }
color = { props.colour ? props.colour : "black" } /> color = { props.colour ? props.colour : "#666" } />
</MenuTrigger> </MenuTrigger>
<MenuOptions customStyles = { optionsStyles }> <MenuOptions customStyles = { optionsStyles }>
{ props.children } { props.children }

View File

@ -21,7 +21,8 @@ import {
ScreenWithBackBarJsx, ScreenWithBackBarJsx,
} from "src/components/navigation/navigators"; } from "src/components/navigation/navigators";
import ModerateMenuJsx from "src/components/moderate-menu.js"; import { MenuOption } from "react-native-popup-menu";
import ContextMenuJsx from "src/components/context-menu.js";
function getMutuals(yourFollowing, theirFollowers) { function getMutuals(yourFollowing, theirFollowers) {
// Where yours and theirs are arrays of followers, as returned by the API // Where yours and theirs are arrays of followers, as returned by the API
@ -125,6 +126,39 @@ const ViewProfileJsx = ({navigation}) => {
}); });
}; };
const _handleHide = async () => {
await requests.muteAccount(
state.instance,
state.profile.id,
state.accessToken,
// Thus, only "mute" statuses
{ notifications: false, }
);
navigation.goBack();
};
const _handleMute = async () => {
await requests.muteAccount(
state.instance,
state.profile.id,
state.accessToken,
);
navigation.goBack();
};
const _handleBlock = async () => {
await requests.blockAccount(
state.instance,
state.profile.id,
state.accessToken,
);
navigation.goBack();
};
return ( return (
<> <>
{ state.loaded { state.loaded
@ -134,6 +168,9 @@ const ViewProfileJsx = ({navigation}) => {
<RawProfileJsx <RawProfileJsx
navigation = { navigation } navigation = { navigation }
onFollow = { _handleFollow } onFollow = { _handleFollow }
onHide = { _handleHide }
onMute = { _handleMute }
onBlock = { _handleBlock }
profile = { state.profile } profile = { state.profile }
mutuals = { state.mutuals } mutuals = { state.mutuals }
followed = { state.followed } followed = { state.followed }
@ -285,9 +322,20 @@ const RawProfileJsx = (props) => {
style = { styles.profileHeaderIcon } /> style = { styles.profileHeaderIcon } />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
: <ModerateMenuJsx : <ContextMenuJsx
triggerStyle = { styles.profileHeaderIcon } containerStyle = {
containerStyle = { styles.profileContextContainer } /> styles.profileContextContainer
}>
<MenuOption
onSelect = { props.onHide }
text = "Don't show me their posts" />
<MenuOption
onSelect = { props.onMute }
text = "Mute" />
<MenuOption
onSelect = { props.onBlock }
text = "Block" />
</ContextMenuJsx>
} }
</View> </View>
<Text style = { styles.accountStats }> <Text style = { styles.accountStats }>