From 61f88ae2b08c15fb2b2b91c0094e3e1adcd8d8e4 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Sat, 21 Oct 2023 12:14:37 -0400 Subject: [PATCH] inherit outline tags of parent post --- src/state/models/ui/shell.ts | 1 + src/view/com/composer/Composer.tsx | 5 +++-- src/view/com/composer/TagInput/index.tsx | 4 +++- src/view/com/composer/TagInput/index.web.tsx | 4 +++- src/view/com/post-thread/PostThreadItem.tsx | 6 +++++- src/view/com/post/Post.tsx | 4 +++- src/view/com/posts/FeedItem.tsx | 5 ++++- src/view/com/util/post-ctrls/PostCtrls.tsx | 3 +++ src/view/screens/PostThread.tsx | 1 + src/view/shell/Composer.tsx | 3 +++ src/view/shell/Composer.web.tsx | 3 +++ src/view/shell/index.tsx | 1 + src/view/shell/index.web.tsx | 1 + 13 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/state/models/ui/shell.ts b/src/state/models/ui/shell.ts index a8937b84ca..4d6c476c33 100644 --- a/src/state/models/ui/shell.ts +++ b/src/state/models/ui/shell.ts @@ -251,6 +251,7 @@ export interface ComposerOpts { onPost?: () => void quote?: ComposerOptsQuote mention?: string // handle of user to mention + outlineTags?: string[] } export class ShellUiModel { diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index eb0c9a806d..79ad416287 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -58,6 +58,7 @@ export const ComposePost = observer(function ComposePost({ onPost, quote: initQuote, mention: initMention, + outlineTags, }: Props) { const {track} = useAnalytics() const pal = usePalette('default') @@ -89,7 +90,7 @@ export const ComposePost = observer(function ComposePost({ const [labels, setLabels] = useState([]) const [suggestedLinks, setSuggestedLinks] = useState>(new Set()) const gallery = useMemo(() => new GalleryModel(store), [store]) - const [tags, setTags] = useState([]) + const [tags, setTags] = useState(outlineTags || []) const onClose = useCallback(() => { store.shell.closeComposer() }, [store]) @@ -455,7 +456,7 @@ export const ComposePost = observer(function ComposePost({ paddingHorizontal: 15, }, ]}> - + diff --git a/src/view/com/composer/TagInput/index.tsx b/src/view/com/composer/TagInput/index.tsx index 2afb2821a1..de637ce61a 100644 --- a/src/view/com/composer/TagInput/index.tsx +++ b/src/view/com/composer/TagInput/index.tsx @@ -27,9 +27,11 @@ import {uniq} from 'lib/strings/helpers' export function TagInput({ max = 8, + initialTags = [], onChangeTags, }: { max?: number + initialTags?: string[] onChangeTags: (tags: string[]) => void }) { const store = useStores() @@ -38,7 +40,7 @@ export function TagInput({ const input = React.useRef(null) const [value, setValue] = React.useState('') - const [tags, setTags] = React.useState([]) + const [tags, setTags] = React.useState(initialTags) const [suggestions, setSuggestions] = React.useState([]) const [isInitialLoad, setIsInitialLoad] = React.useState(true) diff --git a/src/view/com/composer/TagInput/index.web.tsx b/src/view/com/composer/TagInput/index.web.tsx index 8365150b44..5180ad8d1f 100644 --- a/src/view/com/composer/TagInput/index.web.tsx +++ b/src/view/com/composer/TagInput/index.web.tsx @@ -27,9 +27,11 @@ import {uniq} from 'lib/strings/helpers' export function TagInput({ max = 8, + initialTags = [], onChangeTags, }: { max?: number + initialTags?: string[] onChangeTags: (tags: string[]) => void }) { const store = useStores() @@ -43,7 +45,7 @@ export function TagInput({ const containerRef = React.useRef(null) const [value, setValue] = React.useState('') - const [tags, setTags] = React.useState([]) + const [tags, setTags] = React.useState(initialTags) const [dropdownIsOpen, setDropdownIsOpen] = React.useState(false) const [dropdownItems, setDropdownItems] = React.useState< {value: string; label: string}[] diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 4a70e3b921..0f9964f09a 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -57,6 +57,7 @@ export const PostThreadItem = observer(function PostThreadItem({ const itemUri = item.post.uri const itemCid = item.post.cid + const outlineTags = item.postRecord?.tags const itemHref = React.useMemo(() => { const urip = new AtUri(item.post.uri) return makeProfileLink(item.post.author, 'post', urip.rkey) @@ -91,6 +92,7 @@ export const PostThreadItem = observer(function PostThreadItem({ const onPressReply = React.useCallback(() => { store.shell.openComposer({ + outlineTags, replyTo: { uri: item.post.uri, cid: item.post.cid, @@ -103,7 +105,7 @@ export const PostThreadItem = observer(function PostThreadItem({ }, onPost: onPostReply, }) - }, [store, item, record, onPostReply]) + }, [store, item, record, onPostReply, outlineTags]) const onPressToggleRepost = React.useCallback(() => { return item @@ -399,6 +401,7 @@ export const PostThreadItem = observer(function PostThreadItem({ itemCid={itemCid} itemHref={itemHref} itemTitle={itemTitle} + itemOutlineTags={outlineTags} author={item.post.author} text={item.richText?.text || record.text} indexedAt={item.post.indexedAt} @@ -530,6 +533,7 @@ export const PostThreadItem = observer(function PostThreadItem({ itemCid={itemCid} itemHref={itemHref} itemTitle={itemTitle} + itemOutlineTags={outlineTags} author={item.post.author} text={item.richText?.text || record.text} indexedAt={item.post.indexedAt} diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index d5191cf4e0..7cda28c619 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -106,6 +106,7 @@ const PostLoaded = observer(function PostLoadedImpl({ const itemUri = item.post.uri const itemCid = item.post.cid + const outlineTags = item.postRecord?.tags const itemUrip = new AtUri(item.post.uri) const itemHref = makeProfileLink(item.post.author, 'post', itemUrip.rkey) const itemTitle = `Post by ${item.post.author.handle}` @@ -122,6 +123,7 @@ const PostLoaded = observer(function PostLoadedImpl({ const onPressReply = React.useCallback(() => { store.shell.openComposer({ + outlineTags, replyTo: { uri: item.post.uri, cid: item.post.cid, @@ -133,7 +135,7 @@ const PostLoaded = observer(function PostLoadedImpl({ }, }, }) - }, [store, item, record]) + }, [store, item, record, outlineTags]) const onPressToggleRepost = React.useCallback(() => { return item diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 1ceae80ae7..ba016e46ae 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -52,6 +52,7 @@ export const FeedItem = observer(function FeedItemImpl({ const record = item.postRecord const itemUri = item.post.uri const itemCid = item.post.cid + const outlineTags = item.postRecord?.tags const itemHref = useMemo(() => { const urip = new AtUri(item.post.uri) return makeProfileLink(item.post.author, 'post', urip.rkey) @@ -72,6 +73,7 @@ export const FeedItem = observer(function FeedItemImpl({ const onPressReply = React.useCallback(() => { track('FeedItem:PostReply') store.shell.openComposer({ + outlineTags, replyTo: { uri: item.post.uri, cid: item.post.cid, @@ -83,7 +85,7 @@ export const FeedItem = observer(function FeedItemImpl({ }, }, }) - }, [item, track, record, store]) + }, [item, track, record, store, outlineTags]) const onPressToggleRepost = React.useCallback(() => { track('FeedItem:PostRepost') @@ -332,6 +334,7 @@ export const FeedItem = observer(function FeedItemImpl({ itemCid={itemCid} itemHref={itemHref} itemTitle={itemTitle} + itemOutlineTags={outlineTags} author={item.post.author} text={item.richText?.text || record.text} indexedAt={item.post.indexedAt} diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index 5769a478b7..6341589698 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -22,6 +22,7 @@ interface PostCtrlsOpts { itemCid: string itemHref: string itemTitle: string + itemOutlineTags?: string[] isAuthor: boolean author: { did: string @@ -70,6 +71,7 @@ export function PostCtrls(opts: PostCtrlsOpts) { const onQuote = useCallback(() => { store.shell.closeModal() store.shell.openComposer({ + outlineTags: opts.itemOutlineTags, quote: { uri: opts.itemUri, cid: opts.itemCid, @@ -86,6 +88,7 @@ export function PostCtrls(opts: PostCtrlsOpts) { opts.itemUri, opts.text, store.shell, + opts.itemOutlineTags, ]) const onPressToggleLikeWrapper = async () => { diff --git a/src/view/screens/PostThread.tsx b/src/view/screens/PostThread.tsx index d4447f1392..5af68c6223 100644 --- a/src/view/screens/PostThread.tsx +++ b/src/view/screens/PostThread.tsx @@ -54,6 +54,7 @@ export const PostThreadScreen = withAuthRequired( return } store.shell.openComposer({ + outlineTags: view.thread.postRecord?.tags, replyTo: { uri: view.thread.post.uri, cid: view.thread.post.cid, diff --git a/src/view/shell/Composer.tsx b/src/view/shell/Composer.tsx index 219a594edb..30d8814edc 100644 --- a/src/view/shell/Composer.tsx +++ b/src/view/shell/Composer.tsx @@ -13,6 +13,7 @@ export const Composer = observer(function ComposerImpl({ onPost, quote, mention, + outlineTags, }: { active: boolean winHeight: number @@ -20,6 +21,7 @@ export const Composer = observer(function ComposerImpl({ onPost?: ComposerOpts['onPost'] quote?: ComposerOpts['quote'] mention?: ComposerOpts['mention'] + outlineTags?: ComposerOpts['outlineTags'] }) { const pal = usePalette('default') const initInterp = useAnimatedValue(0) @@ -64,6 +66,7 @@ export const Composer = observer(function ComposerImpl({ onPost={onPost} quote={quote} mention={mention} + outlineTags={outlineTags} /> ) diff --git a/src/view/shell/Composer.web.tsx b/src/view/shell/Composer.web.tsx index c3ec37e57f..022ce7db7e 100644 --- a/src/view/shell/Composer.web.tsx +++ b/src/view/shell/Composer.web.tsx @@ -14,6 +14,7 @@ export const Composer = observer(function ComposerImpl({ quote, onPost, mention, + outlineTags, }: { active: boolean winHeight: number @@ -21,6 +22,7 @@ export const Composer = observer(function ComposerImpl({ quote: ComposerOpts['quote'] onPost?: ComposerOpts['onPost'] mention?: ComposerOpts['mention'] + outlineTags?: ComposerOpts['outlineTags'] }) { const pal = usePalette('default') const {isMobile} = useWebMediaQueries() @@ -46,6 +48,7 @@ export const Composer = observer(function ComposerImpl({ quote={quote} onPost={onPost} mention={mention} + outlineTags={outlineTags} /> diff --git a/src/view/shell/index.tsx b/src/view/shell/index.tsx index a4f1cab0c8..66fdf4fdf5 100644 --- a/src/view/shell/index.tsx +++ b/src/view/shell/index.tsx @@ -77,6 +77,7 @@ const ShellInner = observer(function ShellInnerImpl() { onPost={store.shell.composerOpts?.onPost} quote={store.shell.composerOpts?.quote} mention={store.shell.composerOpts?.mention} + outlineTags={store.shell.composerOpts?.outlineTags} /> diff --git a/src/view/shell/index.web.tsx b/src/view/shell/index.web.tsx index 3f2fed69b9..327355fd3a 100644 --- a/src/view/shell/index.web.tsx +++ b/src/view/shell/index.web.tsx @@ -53,6 +53,7 @@ const ShellInner = observer(function ShellInnerImpl() { quote={store.shell.composerOpts?.quote} onPost={store.shell.composerOpts?.onPost} mention={store.shell.composerOpts?.mention} + outlineTags={store.shell.composerOpts?.outlineTags} /> {showBottomBar && }