Pass post-bound dispatch to ComposerPost
This commit is contained in:
@@ -487,7 +487,7 @@ export const ComposePost = ({
|
|||||||
{replyTo ? <ComposerReplyTo replyTo={replyTo} /> : undefined}
|
{replyTo ? <ComposerReplyTo replyTo={replyTo} /> : undefined}
|
||||||
<ComposerPost
|
<ComposerPost
|
||||||
draft={draft}
|
draft={draft}
|
||||||
dispatch={dispatch}
|
dispatch={composerDispatch}
|
||||||
textInput={textInput}
|
textInput={textInput}
|
||||||
isReply={!!replyTo}
|
isReply={!!replyTo}
|
||||||
canRemoveQuote={!initQuote}
|
canRemoveQuote={!initQuote}
|
||||||
@@ -542,7 +542,7 @@ function ComposerPost({
|
|||||||
onPublish,
|
onPublish,
|
||||||
}: {
|
}: {
|
||||||
draft: PostDraft
|
draft: PostDraft
|
||||||
dispatch: (action: PostAction) => void
|
dispatch: (action: ComposerAction) => void
|
||||||
textInput: React.Ref<TextInputRef>
|
textInput: React.Ref<TextInputRef>
|
||||||
isReply: boolean
|
isReply: boolean
|
||||||
canRemoveQuote: boolean
|
canRemoveQuote: boolean
|
||||||
@@ -563,21 +563,32 @@ function ComposerPost({
|
|||||||
? _(msg`Write your reply`)
|
? _(msg`Write your reply`)
|
||||||
: _(msg`What's up?`)
|
: _(msg`What's up?`)
|
||||||
|
|
||||||
|
const dispatchPost = useCallback(
|
||||||
|
(action: PostAction) => {
|
||||||
|
dispatch({
|
||||||
|
type: 'update_post',
|
||||||
|
postId: draft.id,
|
||||||
|
postAction: action,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
[dispatch, draft.id],
|
||||||
|
)
|
||||||
|
|
||||||
const onImageAdd = useCallback(
|
const onImageAdd = useCallback(
|
||||||
(next: ComposerImage[]) => {
|
(next: ComposerImage[]) => {
|
||||||
dispatch({
|
dispatchPost({
|
||||||
type: 'embed_add_images',
|
type: 'embed_add_images',
|
||||||
images: next,
|
images: next,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[dispatch],
|
[dispatchPost],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onNewLink = useCallback(
|
const onNewLink = useCallback(
|
||||||
(uri: string) => {
|
(uri: string) => {
|
||||||
dispatch({type: 'embed_add_uri', uri})
|
dispatchPost({type: 'embed_add_uri', uri})
|
||||||
},
|
},
|
||||||
[dispatch],
|
[dispatchPost],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onPhotoPasted = useCallback(
|
const onPhotoPasted = useCallback(
|
||||||
@@ -611,7 +622,7 @@ function ComposerPost({
|
|||||||
autoFocus
|
autoFocus
|
||||||
webForceMinHeight={forceMinHeight}
|
webForceMinHeight={forceMinHeight}
|
||||||
setRichText={rt => {
|
setRichText={rt => {
|
||||||
dispatch({type: 'update_richtext', richtext: rt})
|
dispatchPost({type: 'update_richtext', richtext: rt})
|
||||||
}}
|
}}
|
||||||
onPhotoPasted={onPhotoPasted}
|
onPhotoPasted={onPhotoPasted}
|
||||||
onNewLink={onNewLink}
|
onNewLink={onNewLink}
|
||||||
@@ -628,7 +639,7 @@ function ComposerPost({
|
|||||||
<ComposerEmbeds
|
<ComposerEmbeds
|
||||||
canRemoveQuote={canRemoveQuote}
|
canRemoveQuote={canRemoveQuote}
|
||||||
embed={draft.embed}
|
embed={draft.embed}
|
||||||
dispatch={dispatch}
|
dispatch={dispatchPost}
|
||||||
clearVideo={onClearVideo}
|
clearVideo={onClearVideo}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user