The tiptap useEditor() hook creates an awkward challenge for passing event handlers into its plugins and native events. By introducing a memoized editor, we should be able to shuttle events out of tiptap without retriggering the useEditor hook. The emitter can then change its registered handlers with each state update.
This commit is contained in:
parent
5e63d3164b
commit
4a59178cd2
4 changed files with 32 additions and 15 deletions
|
@ -151,7 +151,7 @@ export const ComposePost = observer(function ComposePost({
|
|||
[gallery, track],
|
||||
)
|
||||
|
||||
const onPressPublish = async (rt: RichText) => {
|
||||
const onPressPublish = async () => {
|
||||
if (isProcessing || graphemeLength > MAX_GRAPHEME_LENGTH) {
|
||||
return
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ export const ComposePost = observer(function ComposePost({
|
|||
|
||||
setError('')
|
||||
|
||||
if (rt.text.trim().length === 0 && gallery.isEmpty) {
|
||||
if (richtext.text.trim().length === 0 && gallery.isEmpty) {
|
||||
setError('Did you want to say anything?')
|
||||
return
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ export const ComposePost = observer(function ComposePost({
|
|||
|
||||
try {
|
||||
await apilib.post(store, {
|
||||
rawText: rt.text,
|
||||
rawText: richtext.text,
|
||||
replyTo: replyTo?.uri,
|
||||
images: gallery.images,
|
||||
quote,
|
||||
|
@ -245,9 +245,7 @@ export const ComposePost = observer(function ComposePost({
|
|||
) : canPost ? (
|
||||
<TouchableOpacity
|
||||
testID="composerPublishBtn"
|
||||
onPress={() => {
|
||||
onPressPublish(richtext)
|
||||
}}
|
||||
onPress={onPressPublish}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={replyTo ? 'Publish reply' : 'Publish post'}
|
||||
accessibilityHint={
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue