From a0a8f08165230b0a1f85b7e5662055ab174bca7c Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 31 Oct 2023 12:47:28 -0700 Subject: [PATCH] Correctly reflect block by list state --- src/lib/moderation.ts | 15 +++++-- src/state/models/content/profile.ts | 3 +- src/view/com/modals/ModerationDetails.tsx | 21 ++++++++- src/view/com/profile/ProfileHeader.tsx | 53 +++++++++++++---------- 4 files changed, 62 insertions(+), 30 deletions(-) diff --git a/src/lib/moderation.ts b/src/lib/moderation.ts index aadee0e74d..6c08606ee8 100644 --- a/src/lib/moderation.ts +++ b/src/lib/moderation.ts @@ -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') { diff --git a/src/state/models/content/profile.ts b/src/state/models/content/profile.ts index 906f84c281..5333e71166 100644 --- a/src/state/models/content/profile.ts +++ b/src/state/models/content/profile.ts @@ -22,7 +22,8 @@ export class ProfileViewerModel { following?: string followedBy?: string blockedBy?: boolean - blocking?: string; + blocking?: string + blockingByList?: AppBskyGraphDefs.ListViewBasic; [key: string]: unknown constructor() { diff --git a/src/view/com/modals/ModerationDetails.tsx b/src/view/com/modals/ModerationDetails.tsx index bd51845c6d..5fdddb5921 100644 --- a/src/view/com/modals/ModerationDetails.tsx +++ b/src/view/com/modals/ModerationDetails.tsx @@ -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{' '} + {' '} + 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.' diff --git a/src/view/com/profile/ProfileHeader.tsx b/src/view/com/profile/ProfileHeader.tsx index 72396869c9..082fbc0bcd 100644 --- a/src/view/com/profile/ProfileHeader.tsx +++ b/src/view/com/profile/ProfileHeader.tsx @@ -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', @@ -338,6 +340,7 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({ isMe, view.viewer.muted, view.viewer.blocking, + view.viewer.blockingByList, onPressShare, onPressUnmuteAccount, onPressMuteAccount, @@ -370,17 +373,19 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({ ) : view.viewer.blocking ? ( - - - Unblock - - + view.viewer.blockingByList ? null : ( + + + Unblock + + + ) ) : !view.viewer.blockedBy ? ( <> {!isProfilePreview && (