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