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,
langs,
labels,
tags: draft.tags,
})
} catch (e: any) {
logger.error(`Failed to create post`, {
+15 -2
View File
@@ -165,7 +165,13 @@ export const ComposePost = ({
const [draft, dispatch] = useReducer(
composerReducer,
{initImageUris, initQuoteUri: initQuote?.uri, initText, initMention},
{
initImageUris,
initQuoteUri: initQuote?.uri,
initText,
initMention,
initOutlineTags: [],
},
createComposerState,
)
const richtext = draft.richtext
@@ -509,6 +515,13 @@ export const ComposePost = ({
dispatch({type: 'embed_update_gif', alt: altText})
}, [])
const onChangeOutlineTags = useCallback(
(tags: string[]) => {
dispatch({type: 'tags_update', tags})
},
[dispatch],
)
const {
scrollHandler,
onScrollViewContentSizeChange,
@@ -745,7 +758,7 @@ export const ComposePost = ({
</Animated.ScrollView>
<SuggestedLanguage text={richtext.text} />
<OutlineTags onChangeTags={() => {}} />
<OutlineTags onChangeTags={onChangeOutlineTags} />
<Animated.View
style={[a.flex_row, a.p_sm, t.atoms.bg, bottomBarAnimatedStyle]}>
+11
View File
@@ -53,6 +53,7 @@ export type ComposerDraft = {
postgate: AppBskyFeedPostgate.Record
threadgate: ThreadgateAllowUISetting[]
embed: EmbedDraft
tags: string[]
}
export type ComposerAction =
@@ -76,6 +77,7 @@ export type ComposerAction =
| {type: 'embed_add_gif'; gif: Gif}
| {type: 'embed_update_gif'; alt: string}
| {type: 'embed_remove_gif'}
| {type: 'tags_update'; tags: string[]}
export const MAX_IMAGES = 4
@@ -324,6 +326,12 @@ export function composerReducer(
},
}
}
case 'tags_update': {
return {
...state,
tags: action.tags,
}
}
default:
return state
}
@@ -334,11 +342,13 @@ export function createComposerState({
initMention,
initImageUris,
initQuoteUri,
initOutlineTags,
}: {
initText: string | undefined
initMention: string | undefined
initImageUris: ComposerOpts['imageUris']
initQuoteUri: string | undefined
initOutlineTags: string[]
}): ComposerDraft {
let media: ImagesMedia | undefined
if (initImageUris?.length) {
@@ -379,5 +389,6 @@ export function createComposerState({
media,
link: undefined,
},
tags: initOutlineTags,
}
}