diff options
author | Eric Bailey <git@esb.lol> | 2024-08-30 12:26:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-30 12:26:40 -0500 |
commit | c60e8d0772d93fb3b0eca00b5fb1de9e110df320 (patch) | |
tree | 64d293bb596fc06bdd3a54a1265a0b6b3b104b21 /src/state/shell/composer.tsx | |
parent | dbbbba1d32cbb96d9ab98eb871f3618df7f6e628 (diff) | |
download | voidsky-c60e8d0772d93fb3b0eca00b5fb1de9e110df320.tar.zst |
Composer blocks (#5040)
* Move i18n provider up the stack * Protect composer opening for a blocked post * Protect ctrls from interacting with blocked user
Diffstat (limited to 'src/state/shell/composer.tsx')
-rw-r--r-- | src/state/shell/composer.tsx | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/state/shell/composer.tsx b/src/state/shell/composer.tsx index c99005489..74802a993 100644 --- a/src/state/shell/composer.tsx +++ b/src/state/shell/composer.tsx @@ -5,8 +5,11 @@ import { AppBskyRichtextFacet, ModerationDecision, } from '@atproto/api' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' +import * as Toast from '#/view/com/util/Toast' export interface ComposerOptsPostRef { uri: string @@ -22,12 +25,7 @@ export interface ComposerOptsQuote { text: string facets?: AppBskyRichtextFacet.Main[] indexedAt: string - author: { - did: string - handle: string - displayName?: string - avatar?: string - } + author: AppBskyActorDefs.ProfileViewBasic embeds?: AppBskyEmbedRecord.ViewRecord['embeds'] } export interface ComposerOpts { @@ -56,10 +54,25 @@ const controlsContext = React.createContext<ControlsContext>({ }) export function Provider({children}: React.PropsWithChildren<{}>) { + const {_} = useLingui() const [state, setState] = React.useState<StateContext>() const openComposer = useNonReactiveCallback((opts: ComposerOpts) => { - setState(opts) + const author = opts.replyTo?.author || opts.quote?.author + const isBlocked = Boolean( + author && + (author.viewer?.blocking || + author.viewer?.blockedBy || + author.viewer?.blockingByList), + ) + if (isBlocked) { + Toast.show( + _(msg`Cannot interact with a blocked user`), + 'exclamation-circle', + ) + } else { + setState(opts) + } }) const closeComposer = useNonReactiveCallback(() => { |