tangled mirror of catsky-🐱 Soothing soft social-app fork with all the niche toggles! (Unofficial); for issues and PRs please put them on github:NekoDrone/catsky-social

Haptic on profile buttons (#6034)

* play haptic on profile buttons

* change react import

authored by samuel.fm and committed by GitHub fe5a623b fc944841

Changed files
+45 -42
src
+38 -40
src/screens/Profile/Header/ProfileHeaderLabeler.tsx
··· 1 - import React, {memo, useMemo} from 'react' 1 + import {memo, useCallback, useMemo, useState} from 'react' 2 2 import {View} from 'react-native' 3 3 import { 4 4 type AppBskyActorDefs, ··· 84 84 const {mutateAsync: likeMod, isPending: isLikePending} = useLikeMutation() 85 85 const {mutateAsync: unlikeMod, isPending: isUnlikePending} = 86 86 useUnlikeMutation() 87 - const [likeUri, setLikeUri] = React.useState<string>( 88 - labeler.viewer?.like || '', 89 - ) 90 - const [likeCount, setLikeCount] = React.useState(labeler.likeCount || 0) 87 + const [likeUri, setLikeUri] = useState<string>(labeler.viewer?.like || '') 88 + const [likeCount, setLikeCount] = useState(labeler.likeCount || 0) 91 89 92 - const onToggleLiked = React.useCallback(async () => { 90 + const onToggleLiked = useCallback(async () => { 93 91 if (!labeler) { 94 92 return 95 93 } ··· 118 116 119 117 const editProfileControl = useDialogControl() 120 118 121 - const onPressSubscribe = React.useCallback( 122 - () => 123 - requireAuth(async (): Promise<void> => { 124 - const subscribe = !isSubscribed 119 + const onPressSubscribe = useCallback(() => { 120 + requireAuth(async (): Promise<void> => { 121 + playHaptic() 122 + const subscribe = !isSubscribed 125 123 126 - try { 127 - await toggleSubscription({ 128 - did: profile.did, 129 - subscribe, 130 - }) 124 + try { 125 + await toggleSubscription({ 126 + did: profile.did, 127 + subscribe, 128 + }) 131 129 132 - logger.metric( 133 - subscribe 134 - ? 'moderation:subscribedToLabeler' 135 - : 'moderation:unsubscribedFromLabeler', 136 - {}, 137 - {statsig: true}, 138 - ) 139 - } catch (e: any) { 140 - reset() 141 - if (e.message === 'MAX_LABELERS') { 142 - cantSubscribePrompt.open() 143 - return 144 - } 145 - logger.error(`Failed to subscribe to labeler`, {message: e.message}) 130 + logger.metric( 131 + subscribe 132 + ? 'moderation:subscribedToLabeler' 133 + : 'moderation:unsubscribedFromLabeler', 134 + {}, 135 + {statsig: true}, 136 + ) 137 + } catch (e: any) { 138 + reset() 139 + if (e.message === 'MAX_LABELERS') { 140 + cantSubscribePrompt.open() 141 + return 146 142 } 147 - }), 148 - [ 149 - requireAuth, 150 - toggleSubscription, 151 - isSubscribed, 152 - profile, 153 - cantSubscribePrompt, 154 - reset, 155 - ], 156 - ) 143 + logger.error(`Failed to subscribe to labeler`, {message: e.message}) 144 + } 145 + }) 146 + }, [ 147 + playHaptic, 148 + requireAuth, 149 + toggleSubscription, 150 + isSubscribed, 151 + profile, 152 + cantSubscribePrompt, 153 + reset, 154 + ]) 157 155 158 - const isMe = React.useMemo( 156 + const isMe = useMemo( 159 157 () => currentAccount?.did === profile.did, 160 158 [currentAccount, profile], 161 159 )
+7 -2
src/screens/Profile/Header/ProfileHeaderStandard.tsx
··· 10 10 import {useLingui} from '@lingui/react' 11 11 12 12 import {useActorStatus} from '#/lib/actor-status' 13 + import {useHaptics} from '#/lib/haptics' 13 14 import {sanitizeDisplayName} from '#/lib/strings/display-names' 14 15 import {sanitizeHandle} from '#/lib/strings/handles' 15 16 import {logger} from '#/logger' ··· 79 80 profile.viewer?.blocking || 80 81 profile.viewer?.blockedBy || 81 82 profile.viewer?.blockingByList 83 + const playHaptic = useHaptics() 82 84 83 85 const editProfileControl = useDialogControl() 84 86 85 87 const onPressFollow = () => { 86 - setShowSuggestedFollows(true) 88 + playHaptic() 87 89 requireAuth(async () => { 90 + setShowSuggestedFollows(true) 88 91 try { 89 92 await queueFollow() 90 93 Toast.show( ··· 105 108 } 106 109 107 110 const onPressUnfollow = () => { 111 + playHaptic() 108 112 setShowSuggestedFollows(false) 109 113 requireAuth(async () => { 110 114 try { ··· 127 131 } 128 132 129 133 const unblockAccount = useCallback(async () => { 134 + playHaptic() 130 135 try { 131 136 await queueUnblock() 132 137 Toast.show(_(msg({message: 'Account unblocked', context: 'toast'}))) ··· 136 141 Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark') 137 142 } 138 143 } 139 - }, [_, queueUnblock]) 144 + }, [_, queueUnblock, playHaptic]) 140 145 141 146 const isMe = useMemo( 142 147 () => currentAccount?.did === profile.did,