From ca119a30ba2e7d4778eea377dc213399457d5bd8 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 6 Jan 2025 14:16:38 -0600 Subject: [PATCH] Rename, reorg --- src/types/atproto/index.ts | 1 + src/types/{ => atproto}/profile.ts | 10 ++++++---- src/view/com/lists/ListMembers.tsx | 6 +++--- src/view/com/profile/FollowButton.tsx | 4 ++-- src/view/com/profile/ProfileCard.tsx | 14 ++++++++------ 5 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 src/types/atproto/index.ts rename src/types/{ => atproto}/profile.ts (87%) diff --git a/src/types/atproto/index.ts b/src/types/atproto/index.ts new file mode 100644 index 0000000000..58e2a5eb23 --- /dev/null +++ b/src/types/atproto/index.ts @@ -0,0 +1 @@ +export * as profile from '#/types/atproto/profile' diff --git a/src/types/profile.ts b/src/types/atproto/profile.ts similarity index 87% rename from src/types/profile.ts rename to src/types/atproto/profile.ts index a0b78e6fe7..884f10295d 100644 --- a/src/types/profile.ts +++ b/src/types/atproto/profile.ts @@ -21,15 +21,17 @@ export { /** * Matches any profile view exported by our SDK */ -export type AnyView = +export type AnyProfileView = | AppBskyActorDefs.ProfileViewBasic | AppBskyActorDefs.ProfileView | AppBskyActorDefs.ProfileViewDetailed /** - * Downgrades any profile view to the most basic form. + * Maps any profile view type to `ProfileViewBasic`. */ -export function anyToBasic(view: AnyView): AppBskyActorDefs.ProfileViewBasic { +export function anyToBasic( + view: AnyProfileView, +): AppBskyActorDefs.ProfileViewBasic { return { $type: 'app.bsky.actor.defs#profileViewBasic', did: view.did, @@ -44,7 +46,7 @@ export function anyToBasic(view: AnyView): AppBskyActorDefs.ProfileViewBasic { } /** - * Downgrades a detailed profile view to the `ProfileView` form. + * Maps `ProfileViewDetailed` to `ProfileView`. */ export function detailedToView( view: AppBskyActorDefs.ProfileViewDetailed, diff --git a/src/view/com/lists/ListMembers.tsx b/src/view/com/lists/ListMembers.tsx index a43d40b0c3..c8ecfc057a 100644 --- a/src/view/com/lists/ListMembers.tsx +++ b/src/view/com/lists/ListMembers.tsx @@ -11,7 +11,7 @@ import {useModalControls} from '#/state/modals' import {useListMembersQuery} from '#/state/queries/list-members' import {useSession} from '#/state/session' import {ListFooter} from '#/components/Lists' -import * as Profile from '#/types/profile' +import * as atp from '#/types/atproto' import {ProfileCard} from '../profile/ProfileCard' import {ErrorMessage} from '../util/error/ErrorMessage' import {Button} from '../util/forms/Button' @@ -117,7 +117,7 @@ export function ListMembers({ }, [fetchNextPage]) const onPressEditMembership = React.useCallback( - (profile: Profile.AnyView) => { + (profile: atp.profile.AnyProfileView) => { openModal({ name: 'user-add-remove-lists', subject: profile.did, @@ -132,7 +132,7 @@ export function ListMembers({ // = const renderMemberButton = React.useCallback( - (profile: Profile.AnyView) => { + (profile: atp.profile.AnyProfileView) => { if (!isOwner) { return null } diff --git a/src/view/com/profile/FollowButton.tsx b/src/view/com/profile/FollowButton.tsx index 6e24a7c269..6446b7b878 100644 --- a/src/view/com/profile/FollowButton.tsx +++ b/src/view/com/profile/FollowButton.tsx @@ -4,7 +4,7 @@ import {useLingui} from '@lingui/react' import {Shadow} from '#/state/cache/types' import {useProfileFollowMutationQueue} from '#/state/queries/profile' -import * as Profile from '#/types/profile' +import * as atp from '#/types/atproto' import {Button, ButtonType} from '../util/forms/Button' import * as Toast from '../util/Toast' @@ -17,7 +17,7 @@ export function FollowButton({ }: { unfollowedType?: ButtonType followedType?: ButtonType - profile: Shadow + profile: Shadow labelStyle?: StyleProp logContext: 'ProfileCard' | 'StarterPackProfilesList' }) { diff --git a/src/view/com/profile/ProfileCard.tsx b/src/view/com/profile/ProfileCard.tsx index f1b150bb05..8a258498fb 100644 --- a/src/view/com/profile/ProfileCard.tsx +++ b/src/view/com/profile/ProfileCard.tsx @@ -24,7 +24,7 @@ import { shouldShowKnownFollowers, } from '#/components/KnownFollowers' import * as Pills from '#/components/Pills' -import * as Profile from '#/types/profile' +import * as atp from '#/types/atproto' import {Link} from '../util/Link' import {Text} from '../util/text/Text' import {PreviewableUserAvatar} from '../util/UserAvatar' @@ -42,11 +42,13 @@ export function ProfileCard({ showKnownFollowers, }: { testID?: string - profile: Profile.AnyView + profile: atp.profile.AnyProfileView noModFilter?: boolean noBg?: boolean noBorder?: boolean - renderButton?: (profile: Shadow) => React.ReactNode + renderButton?: ( + profile: Shadow, + ) => React.ReactNode onPress?: () => void style?: StyleProp showKnownFollowers?: boolean @@ -59,7 +61,7 @@ export function ProfileCard({ const onBeforePress = React.useCallback(() => { onPress?.() - precacheProfile(queryClient, Profile.anyToBasic(profile)) + precacheProfile(queryClient, atp.profile.anyToBasic(profile)) }, [onPress, profile, queryClient]) if (!moderationOpts) { @@ -125,7 +127,7 @@ export function ProfileCard({ {renderButton(profile)} ) : undefined} - {Profile.isView(profile) || Profile.isDetailedView(profile) ? ( + {atp.profile.isView(profile) || atp.profile.isDetailedView(profile) ? ( <> {profile.description || knownFollowersVisible ? ( @@ -142,7 +144,7 @@ export function ProfileCard({ a.gap_sm, !!profile.description && a.mt_md, ]}> - {Profile.isDetailedView(profile) && ( + {atp.profile.isDetailedView(profile) && (