Bluesky app fork with some witchin' additions 💫

Mute account from post (#7712)

* mute account from post

* move options around

authored by samuel.fm and committed by

GitHub ca70aacb e6bfeb1b

+51 -1
+51 -1
src/view/com/util/forms/PostDropdownBtnMenuItems.tsx
··· 41 41 } from '#/state/queries/post' 42 42 import {useToggleQuoteDetachmentMutation} from '#/state/queries/postgate' 43 43 import {getMaybeDetachedQuoteEmbed} from '#/state/queries/postgate/util' 44 - import {useProfileBlockMutationQueue} from '#/state/queries/profile' 44 + import { 45 + useProfileBlockMutationQueue, 46 + useProfileMuteMutationQueue, 47 + } from '#/state/queries/profile' 45 48 import {useToggleReplyVisibilityMutation} from '#/state/queries/threadgate' 46 49 import {useSession} from '#/state/session' 47 50 import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies' ··· 65 68 import {Eye_Stroke2_Corner0_Rounded as Eye} from '#/components/icons/Eye' 66 69 import {EyeSlash_Stroke2_Corner0_Rounded as EyeSlash} from '#/components/icons/EyeSlash' 67 70 import {Filter_Stroke2_Corner0_Rounded as Filter} from '#/components/icons/Filter' 71 + import {Mute_Stroke2_Corner0_Rounded as MuteIcon} from '#/components/icons/Mute' 68 72 import {Mute_Stroke2_Corner0_Rounded as Mute} from '#/components/icons/Mute' 69 73 import {PaperPlane_Stroke2_Corner0_Rounded as Send} from '#/components/icons/PaperPlane' 70 74 import {PersonX_Stroke2_Corner0_Rounded as PersonX} from '#/components/icons/Person' 71 75 import {Pin_Stroke2_Corner0_Rounded as PinIcon} from '#/components/icons/Pin' 72 76 import {SettingsGear2_Stroke2_Corner0_Rounded as Gear} from '#/components/icons/SettingsGear2' 77 + import {SpeakerVolumeFull_Stroke2_Corner0_Rounded as UnmuteIcon} from '#/components/icons/Speaker' 73 78 import {SpeakerVolumeFull_Stroke2_Corner0_Rounded as Unmute} from '#/components/icons/Speaker' 74 79 import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash' 75 80 import {Warning_Stroke2_Corner0_Rounded as Warning} from '#/components/icons/Warning' ··· 155 160 useToggleQuoteDetachmentMutation() 156 161 157 162 const [queueBlock] = useProfileBlockMutationQueue(postAuthor) 163 + const [queueMute, queueUnmute] = useProfileMuteMutationQueue(postAuthor) 158 164 159 165 const prefetchPostInteractionSettings = usePrefetchPostInteractionSettings({ 160 166 postUri: post.uri, ··· 368 374 } 369 375 }, [_, queueBlock]) 370 376 377 + const onMuteAuthor = useCallback(async () => { 378 + if (postAuthor.viewer?.muted) { 379 + try { 380 + await queueUnmute() 381 + Toast.show(_(msg`Account unmuted`)) 382 + } catch (e: any) { 383 + if (e?.name !== 'AbortError') { 384 + logger.error('Failed to unmute account', {message: e}) 385 + Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark') 386 + } 387 + } 388 + } else { 389 + try { 390 + await queueMute() 391 + Toast.show(_(msg`Account muted`)) 392 + } catch (e: any) { 393 + if (e?.name !== 'AbortError') { 394 + logger.error('Failed to mute account', {message: e}) 395 + Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark') 396 + } 397 + } 398 + } 399 + }, [_, queueMute, queueUnmute, postAuthor.viewer?.muted]) 400 + 371 401 const onShareATURI = useCallback(() => { 372 402 shareText(postUri) 373 403 }, [postUri]) ··· 607 637 <Menu.Group> 608 638 {!isAuthor && ( 609 639 <> 640 + <Menu.Item 641 + testID="postDropdownMuteBtn" 642 + label={ 643 + postAuthor.viewer?.muted 644 + ? _(msg`Unmute account`) 645 + : _(msg`Mute account`) 646 + } 647 + onPress={onMuteAuthor}> 648 + <Menu.ItemText> 649 + {postAuthor.viewer?.muted 650 + ? _(msg`Unmute account`) 651 + : _(msg`Mute account`)} 652 + </Menu.ItemText> 653 + <Menu.ItemIcon 654 + icon={postAuthor.viewer?.muted ? UnmuteIcon : MuteIcon} 655 + position="right" 656 + /> 657 + </Menu.Item> 658 + 610 659 {!postAuthor.viewer?.blocking && ( 611 660 <Menu.Item 612 661 testID="postDropdownBlockBtn" ··· 616 665 <Menu.ItemIcon icon={PersonX} position="right" /> 617 666 </Menu.Item> 618 667 )} 668 + 619 669 <Menu.Item 620 670 testID="postDropdownReportBtn" 621 671 label={_(msg`Report post`)}