Create post with outline tags

This commit is contained in:
Eric Bailey
2024-10-22 14:22:49 -05:00
parent 5607c06bad
commit 8b55596d5e
3 changed files with 27 additions and 2 deletions
+1
View File
@@ -111,6 +111,7 @@ export async function post(
embed, embed,
langs, langs,
labels, labels,
tags: draft.tags,
}) })
} catch (e: any) { } catch (e: any) {
logger.error(`Failed to create post`, { logger.error(`Failed to create post`, {
+15 -2
View File
@@ -165,7 +165,13 @@ export const ComposePost = ({
const [draft, dispatch] = useReducer( const [draft, dispatch] = useReducer(
composerReducer, composerReducer,
{initImageUris, initQuoteUri: initQuote?.uri, initText, initMention}, {
initImageUris,
initQuoteUri: initQuote?.uri,
initText,
initMention,
initOutlineTags: [],
},
createComposerState, createComposerState,
) )
const richtext = draft.richtext const richtext = draft.richtext
@@ -509,6 +515,13 @@ export const ComposePost = ({
dispatch({type: 'embed_update_gif', alt: altText}) dispatch({type: 'embed_update_gif', alt: altText})
}, []) }, [])
const onChangeOutlineTags = useCallback(
(tags: string[]) => {
dispatch({type: 'tags_update', tags})
},
[dispatch],
)
const { const {
scrollHandler, scrollHandler,
onScrollViewContentSizeChange, onScrollViewContentSizeChange,
@@ -745,7 +758,7 @@ export const ComposePost = ({
</Animated.ScrollView> </Animated.ScrollView>
<SuggestedLanguage text={richtext.text} /> <SuggestedLanguage text={richtext.text} />
<OutlineTags onChangeTags={() => {}} /> <OutlineTags onChangeTags={onChangeOutlineTags} />
<Animated.View <Animated.View
style={[a.flex_row, a.p_sm, t.atoms.bg, bottomBarAnimatedStyle]}> style={[a.flex_row, a.p_sm, t.atoms.bg, bottomBarAnimatedStyle]}>
+11
View File
@@ -53,6 +53,7 @@ export type ComposerDraft = {
postgate: AppBskyFeedPostgate.Record postgate: AppBskyFeedPostgate.Record
threadgate: ThreadgateAllowUISetting[] threadgate: ThreadgateAllowUISetting[]
embed: EmbedDraft embed: EmbedDraft
tags: string[]
} }
export type ComposerAction = export type ComposerAction =
@@ -76,6 +77,7 @@ export type ComposerAction =
| {type: 'embed_add_gif'; gif: Gif} | {type: 'embed_add_gif'; gif: Gif}
| {type: 'embed_update_gif'; alt: string} | {type: 'embed_update_gif'; alt: string}
| {type: 'embed_remove_gif'} | {type: 'embed_remove_gif'}
| {type: 'tags_update'; tags: string[]}
export const MAX_IMAGES = 4 export const MAX_IMAGES = 4
@@ -324,6 +326,12 @@ export function composerReducer(
}, },
} }
} }
case 'tags_update': {
return {
...state,
tags: action.tags,
}
}
default: default:
return state return state
} }
@@ -334,11 +342,13 @@ export function createComposerState({
initMention, initMention,
initImageUris, initImageUris,
initQuoteUri, initQuoteUri,
initOutlineTags,
}: { }: {
initText: string | undefined initText: string | undefined
initMention: string | undefined initMention: string | undefined
initImageUris: ComposerOpts['imageUris'] initImageUris: ComposerOpts['imageUris']
initQuoteUri: string | undefined initQuoteUri: string | undefined
initOutlineTags: string[]
}): ComposerDraft { }): ComposerDraft {
let media: ImagesMedia | undefined let media: ImagesMedia | undefined
if (initImageUris?.length) { if (initImageUris?.length) {
@@ -379,5 +389,6 @@ export function createComposerState({
media, media,
link: undefined, link: undefined,
}, },
tags: initOutlineTags,
} }
} }