Implement account muting

This commit is contained in:
Paul Frazee 2023-01-02 13:40:14 -06:00
parent 3972706c54
commit 8cd2b4a721
12 changed files with 101 additions and 15 deletions

View file

@ -89,6 +89,24 @@ export const ProfileHeader = observer(function ProfileHeader({
}
onRefreshAll()
}
const onPressMuteAccount = async () => {
try {
await view.muteAccount()
Toast.show('Account muted')
} catch (e: any) {
console.error(e)
Toast.show(`There was an issue! ${e.toString()}`)
}
}
const onPressUnmuteAccount = async () => {
try {
await view.unmuteAccount()
Toast.show('Account unmuted')
} catch (e: any) {
console.error(e)
Toast.show(`There was an issue! ${e.toString()}`)
}
}
const onPressReportAccount = () => {
store.shell.openModal(new ReportAccountModal(view.did))
}
@ -143,6 +161,10 @@ export const ProfileHeader = observer(function ProfileHeader({
let dropdownItems: DropdownItem[] | undefined
if (!isMe) {
dropdownItems = dropdownItems || []
dropdownItems.push({
label: view.myState.muted ? 'Unmute Account' : 'Mute Account',
onPress: view.myState.muted ? onPressUnmuteAccount : onPressMuteAccount,
})
dropdownItems.push({
label: 'Report Account',
onPress: onPressReportAccount,
@ -286,7 +308,7 @@ export const ProfileHeader = observer(function ProfileHeader({
/>
) : undefined}
{view.isScene && view.creator ? (
<View style={styles.relationshipsLine}>
<View style={styles.detailLine}>
<FontAwesomeIcon
icon={['far', 'user']}
style={[pal.textLight, s.mr5]}
@ -304,7 +326,7 @@ export const ProfileHeader = observer(function ProfileHeader({
</View>
) : undefined}
{view.isScene && view.myState.member ? (
<View style={styles.relationshipsLine}>
<View style={styles.detailLine}>
<FontAwesomeIcon
icon={['far', 'circle-check']}
style={[pal.textLight, s.mr5]}
@ -314,6 +336,17 @@ export const ProfileHeader = observer(function ProfileHeader({
</Text>
</View>
) : undefined}
{view.myState.muted ? (
<View style={[styles.detailLine, pal.btn, s.p5]}>
<FontAwesomeIcon
icon={['far', 'eye-slash']}
style={[pal.text, s.mr5]}
/>
<Text type="body2" style={[s.mr2, pal.text]}>
Account muted.
</Text>
</View>
) : undefined}
</View>
{view.isScene && view.creator === store.me.did ? (
<View style={[styles.sceneAdminContainer, pal.border]}>
@ -421,7 +454,7 @@ const styles = StyleSheet.create({
marginBottom: 8,
},
relationshipsLine: {
detailLine: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 5,