Skip to content

Commit

Permalink
Correctly reflect block by list state
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed Oct 31, 2023
1 parent c104dba commit a0a8f08
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 30 deletions.
15 changes: 12 additions & 3 deletions src/lib/moderation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@ export function describeModerationCause(
}
}
if (cause.type === 'blocking') {
return {
name: 'User Blocked',
description: 'You have blocked this user. You cannot view their content.',
if (cause.source.type === 'list') {
return {
name: `User Blocked by "${cause.source.list.name}"`,
description:
'You have blocked this user. You cannot view their content.',
}
} else {
return {
name: 'User Blocked',
description:
'You have blocked this user. You cannot view their content.',
}
}
}
if (cause.type === 'blocked-by') {
Expand Down
3 changes: 2 additions & 1 deletion src/state/models/content/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class ProfileViewerModel {
following?: string
followedBy?: string
blockedBy?: boolean
blocking?: string;
blocking?: string
blockingByList?: AppBskyGraphDefs.ListViewBasic;
[key: string]: unknown

constructor() {
Expand Down
21 changes: 19 additions & 2 deletions src/view/com/modals/ModerationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,25 @@ export function Component({
description =
'Moderator has chosen to set a general warning on the content.'
} else if (moderation.cause.type === 'blocking') {
name = 'User Blocked'
description = 'You have blocked this user. You cannot view their content.'
if (moderation.cause.source.type === 'list') {
const list = moderation.cause.source.list
name = 'User Blocked by List'
description = (
<>
This user is included the{' '}
<TextLink
type="2xl"
href={listUriToHref(list.uri)}
text={list.name}
style={pal.link}
/>{' '}
list which you have blocked.
</>
)
} else {
name = 'User Blocked'
description = 'You have blocked this user. You cannot view their content.'
}
} else if (moderation.cause.type === 'blocked-by') {
name = 'User Blocks You'
description = 'This user has blocked you. You cannot view their content.'
Expand Down
53 changes: 29 additions & 24 deletions src/view/com/profile/ProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,22 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
},
})
}
items.push({
testID: 'profileHeaderDropdownBlockBtn',
label: view.viewer.blocking ? 'Unblock Account' : 'Block Account',
onPress: view.viewer.blocking
? onPressUnblockAccount
: onPressBlockAccount,
icon: {
ios: {
name: 'person.fill.xmark',
if (!view.viewer.blockingByList) {
items.push({
testID: 'profileHeaderDropdownBlockBtn',
label: view.viewer.blocking ? 'Unblock Account' : 'Block Account',
onPress: view.viewer.blocking
? onPressUnblockAccount
: onPressBlockAccount,
icon: {
ios: {
name: 'person.fill.xmark',
},
android: 'ic_menu_close_clear_cancel',
web: 'user-slash',
},
android: 'ic_menu_close_clear_cancel',
web: 'user-slash',
},
})
})
}
items.push({
testID: 'profileHeaderDropdownReportBtn',
label: 'Report Account',
Expand All @@ -338,6 +340,7 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
isMe,
view.viewer.muted,
view.viewer.blocking,
view.viewer.blockingByList,
onPressShare,
onPressUnmuteAccount,
onPressMuteAccount,
Expand Down Expand Up @@ -370,17 +373,19 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
</Text>
</TouchableOpacity>
) : view.viewer.blocking ? (
<TouchableOpacity
testID="unblockBtn"
onPress={onPressUnblockAccount}
style={[styles.btn, styles.mainBtn, pal.btn]}
accessibilityRole="button"
accessibilityLabel="Unblock"
accessibilityHint="">
<Text type="button" style={[pal.text, s.bold]}>
Unblock
</Text>
</TouchableOpacity>
view.viewer.blockingByList ? null : (
<TouchableOpacity
testID="unblockBtn"
onPress={onPressUnblockAccount}
style={[styles.btn, styles.mainBtn, pal.btn]}
accessibilityRole="button"
accessibilityLabel="Unblock"
accessibilityHint="">
<Text type="button" style={[pal.text, s.bold]}>
Unblock
</Text>
</TouchableOpacity>
)
) : !view.viewer.blockedBy ? (
<>
{!isProfilePreview && (
Expand Down

0 comments on commit a0a8f08

Please sign in to comment.