inherit outline tags of parent post

This commit is contained in:
Eric Bailey
2023-10-21 12:14:37 -04:00
parent a5d4cfda9b
commit 61f88ae2b0
13 changed files with 34 additions and 7 deletions
+1
View File
@@ -251,6 +251,7 @@ export interface ComposerOpts {
onPost?: () => void
quote?: ComposerOptsQuote
mention?: string // handle of user to mention
outlineTags?: string[]
}
export class ShellUiModel {
+3 -2
View File
@@ -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<string[]>([])
const [suggestedLinks, setSuggestedLinks] = useState<Set<string>>(new Set())
const gallery = useMemo(() => new GalleryModel(store), [store])
const [tags, setTags] = useState<string[]>([])
const [tags, setTags] = useState<string[]>(outlineTags || [])
const onClose = useCallback(() => {
store.shell.closeComposer()
}, [store])
@@ -455,7 +456,7 @@ export const ComposePost = observer(function ComposePost({
paddingHorizontal: 15,
},
]}>
<TagInput onChangeTags={onChangeTags} />
<TagInput initialTags={tags} onChangeTags={onChangeTags} />
</View>
<View style={[pal.border, styles.bottomBar]}>
+3 -1
View File
@@ -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<TextInput>(null)
const [value, setValue] = React.useState('')
const [tags, setTags] = React.useState<string[]>([])
const [tags, setTags] = React.useState<string[]>(initialTags)
const [suggestions, setSuggestions] = React.useState<string[]>([])
const [isInitialLoad, setIsInitialLoad] = React.useState(true)
+3 -1
View File
@@ -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<HTMLDivElement>(null)
const [value, setValue] = React.useState('')
const [tags, setTags] = React.useState<string[]>([])
const [tags, setTags] = React.useState<string[]>(initialTags)
const [dropdownIsOpen, setDropdownIsOpen] = React.useState(false)
const [dropdownItems, setDropdownItems] = React.useState<
{value: string; label: string}[]
+5 -1
View File
@@ -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}
+3 -1
View File
@@ -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
+4 -1
View File
@@ -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}
@@ -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 () => {
+1
View File
@@ -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,
+3
View File
@@ -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}
/>
</Animated.View>
)
+3
View File
@@ -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}
/>
</View>
</View>
+1
View File
@@ -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}
/>
<ModalsContainer />
<Lightbox />
+1
View File
@@ -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 && <BottomBarWeb />}
<ModalsContainer />