diff options
Diffstat (limited to 'src/view/com/composer/Composer.tsx')
-rw-r--r-- | src/view/com/composer/Composer.tsx | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 52b90b6c7..fc324d3e5 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -92,18 +92,24 @@ export const ComposePost = observer(function ComposePost({ const onPressCancel = useCallback(() => { if (graphemeLength > 0 || !gallery.isEmpty) { + if (store.shell.activeModals.some(modal => modal.name === 'confirm')) { + store.shell.closeModal() + } store.shell.openModal({ name: 'confirm', - title: 'Cancel draft', - onPressConfirm: onClose, + title: 'Discard draft', + onPressConfirm: hackfixOnClose, onPressCancel: () => { store.shell.closeModal() }, - message: "Are you sure you'd like to cancel this draft?", + message: "Are you sure you'd like to discard this draft?", + confirmBtnText: 'Discard', + confirmBtnStyle: {backgroundColor: colors.red4}, }) + } else { + hackfixOnClose() } - hackfixOnClose() - }, [store, hackfixOnClose, graphemeLength, gallery, onClose]) + }, [store, hackfixOnClose, graphemeLength, gallery]) // initial setup useEffect(() => { @@ -114,14 +120,10 @@ export const ComposePost = observer(function ComposePost({ const onEscape = useCallback( (e: KeyboardEvent) => { if (e.key === 'Escape') { - if (store.shell.activeModals.some(modal => modal.name === 'confirm')) { - store.shell.closeModal() - } - onPressCancel() } }, - [store, onPressCancel], + [onPressCancel], ) useEffect(() => { if (isDesktopWeb) { @@ -172,9 +174,6 @@ export const ComposePost = observer(function ComposePost({ knownHandles: autocompleteView.knownHandles, langs: store.preferences.postLanguages, }) - track('Create Post', { - imageCount: gallery.size, - }) } catch (e: any) { if (extLink) { setExtLink({ @@ -186,6 +185,11 @@ export const ComposePost = observer(function ComposePost({ setError(cleanError(e.message)) setIsProcessing(false) return + } finally { + track('Create Post', { + imageCount: gallery.size, + }) + if (replyTo && replyTo.uri) track('Post:Reply') } if (!replyTo) { await store.me.mainFeed.addPostToTop(createdPost.uri) @@ -227,13 +231,13 @@ export const ComposePost = observer(function ComposePost({ <View style={[s.flex1, viewStyles]} aria-modal accessibilityViewIsModal> <View style={styles.topbar}> <TouchableOpacity - testID="composerCancelButton" + testID="composerDiscardButton" onPress={onPressCancel} onAccessibilityEscape={onPressCancel} accessibilityRole="button" - accessibilityLabel="Cancel" - accessibilityHint="Closes post composer"> - <Text style={[pal.link, s.f18]}>Cancel</Text> + accessibilityLabel="Discard" + accessibilityHint="Closes post composer and discards post draft"> + <Text style={[pal.link, s.f18, styles.discard]}>Discard</Text> </TouchableOpacity> <View style={s.flex1} /> {isProcessing ? ( @@ -386,6 +390,9 @@ const styles = StyleSheet.create({ paddingHorizontal: 20, height: 55, }, + discard: { + color: colors.red3, + }, postBtn: { borderRadius: 20, paddingHorizontal: 20, |