Bluesky app fork with some witchin' additions 💫

rm unused follow button (#9332)

authored by samuel.fm and committed by

GitHub 5208aa4a 1cdb105a

-85
-85
src/view/com/profile/FollowButton.tsx
··· 1 - import {type StyleProp, type TextStyle, View} from 'react-native' 2 - import {msg} from '@lingui/macro' 3 - import {useLingui} from '@lingui/react' 4 - 5 - import {type Shadow} from '#/state/cache/types' 6 - import {useProfileFollowMutationQueue} from '#/state/queries/profile' 7 - import type * as bsky from '#/types/bsky' 8 - import {Button, type ButtonType} from '../util/forms/Button' 9 - import * as Toast from '../util/Toast' 10 - 11 - export function FollowButton({ 12 - unfollowedType = 'inverted', 13 - followedType = 'default', 14 - profile, 15 - labelStyle, 16 - logContext, 17 - onFollow, 18 - }: { 19 - unfollowedType?: ButtonType 20 - followedType?: ButtonType 21 - profile: Shadow<bsky.profile.AnyProfileView> 22 - labelStyle?: StyleProp<TextStyle> 23 - logContext: 'ProfileCard' | 'StarterPackProfilesList' 24 - onFollow?: () => void 25 - }) { 26 - const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue( 27 - profile, 28 - logContext, 29 - ) 30 - const {_} = useLingui() 31 - 32 - const onPressFollow = async () => { 33 - try { 34 - await queueFollow() 35 - onFollow?.() 36 - } catch (e: any) { 37 - if (e?.name !== 'AbortError') { 38 - Toast.show(_(msg`An issue occurred, please try again.`), 'xmark') 39 - } 40 - } 41 - } 42 - 43 - const onPressUnfollow = async () => { 44 - try { 45 - await queueUnfollow() 46 - } catch (e: any) { 47 - if (e?.name !== 'AbortError') { 48 - Toast.show(_(msg`An issue occurred, please try again.`), 'xmark') 49 - } 50 - } 51 - } 52 - 53 - if (!profile.viewer) { 54 - return <View /> 55 - } 56 - 57 - if (profile.viewer.following) { 58 - return ( 59 - <Button 60 - type={followedType} 61 - labelStyle={labelStyle} 62 - onPress={onPressUnfollow} 63 - label={_(msg({message: 'Unfollow', context: 'action'}))} 64 - /> 65 - ) 66 - } else if (!profile.viewer.followedBy) { 67 - return ( 68 - <Button 69 - type={unfollowedType} 70 - labelStyle={labelStyle} 71 - onPress={onPressFollow} 72 - label={_(msg({message: 'Follow', context: 'action'}))} 73 - /> 74 - ) 75 - } else { 76 - return ( 77 - <Button 78 - type={unfollowedType} 79 - labelStyle={labelStyle} 80 - onPress={onPressFollow} 81 - label={_(msg({message: 'Follow back', context: 'action'}))} 82 - /> 83 - ) 84 - } 85 - }