Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Disable Post button when empty (#5953)

* Disable Post button when empty

* Use regular disabled button

* Disable post on video error until cleared

authored by

dan and committed by
GitHub
3bf91eb8 9c27d83d

+19 -32
+19 -32
src/view/com/composer/Composer.tsx
··· 293 293 return false 294 294 }, [images, extGifAlt, extGif, requireAltTextEnabled]) 295 295 296 + const isEmptyPost = 297 + richtext.text.trim().length === 0 && 298 + images.length === 0 && 299 + !extLink && 300 + !extGif && 301 + !quote && 302 + videoState.status === 'idle' 303 + 304 + const canPost = 305 + graphemeLength <= MAX_GRAPHEME_LENGTH && 306 + !isAltTextRequiredAndMissing && 307 + !isEmptyPost && 308 + videoState.status !== 'error' 309 + 296 310 const onPressPublish = React.useCallback( 297 311 async (finishedUploading: boolean) => { 298 - if (isPublishing || graphemeLength > MAX_GRAPHEME_LENGTH) { 312 + if (isPublishing) { 299 313 return 300 314 } 301 315 302 - if (isAltTextRequiredAndMissing) { 316 + if (!canPost) { 303 317 return 304 318 } 305 319 ··· 313 327 } 314 328 315 329 setError('') 316 - 317 - if ( 318 - richtext.text.trim().length === 0 && 319 - images.length === 0 && 320 - !extLink && 321 - !extGif && 322 - !quote && 323 - videoState.status === 'idle' 324 - ) { 325 - setError(_(msg`Did you want to say anything?`)) 326 - return 327 - } 328 - 329 330 setIsPublishing(true) 330 331 331 332 let postUri ··· 410 411 agent, 411 412 draft, 412 413 extLink, 413 - extGif, 414 414 images, 415 - graphemeLength, 416 - isAltTextRequiredAndMissing, 415 + canPost, 417 416 isPublishing, 418 417 langPrefs.postLanguage, 419 418 onClose, ··· 421 420 quote, 422 421 initQuote, 423 422 replyTo, 424 - richtext.text, 425 423 setLangPrefs, 426 424 videoState.asset, 427 425 videoState.status, ··· 437 435 } 438 436 } 439 437 }, [onPressPublish, publishOnUpload, videoState.pendingPublish]) 440 - 441 - const canPost = useMemo( 442 - () => graphemeLength <= MAX_GRAPHEME_LENGTH && !isAltTextRequiredAndMissing, 443 - [graphemeLength, isAltTextRequiredAndMissing], 444 - ) 445 438 446 439 const onEmojiButtonPress = useCallback(() => { 447 440 openEmojiPicker?.(textInput.current?.getCursorPosition()) ··· 692 685 <ActivityIndicator /> 693 686 </View> 694 687 </> 695 - ) : canPost ? ( 688 + ) : ( 696 689 <Button 697 690 testID="composerPublishBtn" 698 691 label={isReply ? 'Publish reply' : 'Publish post'} ··· 702 695 size="small" 703 696 style={[a.rounded_full, a.py_sm]} 704 697 onPress={onPublish} 705 - disabled={isPublishQueued}> 698 + disabled={!canPost || isPublishQueued}> 706 699 <ButtonText style={[a.text_md]}> 707 700 {isReply ? ( 708 701 <Trans context="action">Reply</Trans> ··· 711 704 )} 712 705 </ButtonText> 713 706 </Button> 714 - ) : ( 715 - <View style={[styles.postBtn, pal.btn]}> 716 - <Text style={[pal.textLight, s.f16, s.bold]}> 717 - <Trans context="action">Post</Trans> 718 - </Text> 719 - </View> 720 707 )} 721 708 </View> 722 709 {children}