Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Show feedback for Follow button in interstitials (#4738)

* Fix Follow in interstitials

* Show feedback in toast

authored by

dan and committed by
GitHub
09dfc9ed d5fd19df

+42 -3
+1
src/components/FeedInterstitials.tsx
··· 212 212 /> 213 213 <ProfileCard.FollowButton 214 214 profile={profile} 215 + moderationOpts={moderationOpts} 215 216 logContext="FeedInterstitial" 216 217 color="secondary_inverted" 217 218 shape="round"
+24 -1
src/components/ProfileCard.tsx
··· 62 62 <Header> 63 63 <Avatar profile={profile} moderationOpts={moderationOpts} /> 64 64 <NameAndHandle profile={profile} moderationOpts={moderationOpts} /> 65 - <FollowButton profile={profile} logContext={logContext} /> 65 + <FollowButton 66 + profile={profile} 67 + moderationOpts={moderationOpts} 68 + logContext={logContext} 69 + /> 66 70 </Header> 67 71 68 72 <ProfileCardPills ··· 261 265 262 266 export type FollowButtonProps = { 263 267 profile: AppBskyActorDefs.ProfileViewBasic 268 + moderationOpts: ModerationOpts 264 269 logContext: LogEvents['profile:follow']['logContext'] & 265 270 LogEvents['profile:unfollow']['logContext'] 266 271 } & Partial<ButtonProps> ··· 273 278 274 279 export function FollowButtonInner({ 275 280 profile: profileUnshadowed, 281 + moderationOpts, 276 282 logContext, 277 283 ...rest 278 284 }: FollowButtonProps) { 279 285 const {_} = useLingui() 280 286 const profile = useProfileShadow(profileUnshadowed) 287 + const moderation = moderateProfile(profile, moderationOpts) 281 288 const [queueFollow, queueUnfollow] = useProfileFollowMutationQueue( 282 289 profile, 283 290 logContext, ··· 289 296 e.stopPropagation() 290 297 try { 291 298 await queueFollow() 299 + Toast.show( 300 + _( 301 + msg`Following ${sanitizeDisplayName( 302 + profile.displayName || profile.handle, 303 + moderation.ui('displayName'), 304 + )}`, 305 + ), 306 + ) 292 307 } catch (e: any) { 293 308 if (e?.name !== 'AbortError') { 294 309 Toast.show(_(msg`An issue occurred, please try again.`)) ··· 301 316 e.stopPropagation() 302 317 try { 303 318 await queueUnfollow() 319 + Toast.show( 320 + _( 321 + msg`No longer following ${sanitizeDisplayName( 322 + profile.displayName || profile.handle, 323 + moderation.ui('displayName'), 324 + )}`, 325 + ), 326 + ) 304 327 } catch (e: any) { 305 328 if (e?.name !== 'AbortError') { 306 329 Toast.show(_(msg`An issue occurred, please try again.`))
+17 -2
src/state/queries/profile.ts
··· 3 3 import { 4 4 AppBskyActorDefs, 5 5 AppBskyActorGetProfile, 6 + AppBskyActorGetProfiles, 6 7 AppBskyActorProfile, 7 8 AtUri, 8 9 BskyAgent, ··· 516 517 queryClient: QueryClient, 517 518 did: string, 518 519 ): Generator<AppBskyActorDefs.ProfileViewDetailed, void> { 519 - const queryDatas = 520 + const profileQueryDatas = 520 521 queryClient.getQueriesData<AppBskyActorDefs.ProfileViewDetailed>({ 521 522 queryKey: [RQKEY_ROOT], 522 523 }) 523 - for (const [_queryKey, queryData] of queryDatas) { 524 + for (const [_queryKey, queryData] of profileQueryDatas) { 524 525 if (!queryData) { 525 526 continue 526 527 } 527 528 if (queryData.did === did) { 528 529 yield queryData 530 + } 531 + } 532 + const profilesQueryDatas = 533 + queryClient.getQueriesData<AppBskyActorGetProfiles.OutputSchema>({ 534 + queryKey: [profilesQueryKeyRoot], 535 + }) 536 + for (const [_queryKey, queryData] of profilesQueryDatas) { 537 + if (!queryData) { 538 + continue 539 + } 540 + for (let profile of queryData.profiles) { 541 + if (profile.did === did) { 542 + yield profile 543 + } 529 544 } 530 545 } 531 546 }