From 85f0b8bc2b8d731aff12675c69a58c53c716ed28 Mon Sep 17 00:00:00 2001 From: feruz Date: Fri, 10 Jan 2020 05:15:48 +0200 Subject: [PATCH 1/5] post edit unmmount update fix --- src/screens/editor/container/editorContainer.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/screens/editor/container/editorContainer.js b/src/screens/editor/container/editorContainer.js index 226609b36..150206164 100644 --- a/src/screens/editor/container/editorContainer.js +++ b/src/screens/editor/container/editorContainer.js @@ -282,6 +282,10 @@ class EditorContainer extends Component { ), ); + this.setState({ isPostSending: false }); + + setDraftPost({ title: '', body: '', tags: '' }, currentAccount.name); + navigation.navigate({ routeName: ROUTES.SCREENS.POST, params: { @@ -291,10 +295,6 @@ class EditorContainer extends Component { }, key: permlink, }); - - this.setState({ isPostSending: false }); - - setDraftPost({ title: '', body: '', tags: '' }, currentAccount.name); }) .catch(error => { this._handleSubmitFailure(error); @@ -410,12 +410,11 @@ class EditorContainer extends Component { _handleSubmitSuccess = () => { const { navigation } = this.props; - if (navigation) { - navigation.goBack(); - navigation.state.params.fetchPost(); - } - this.stateTimer = setTimeout(() => { + if (navigation) { + navigation.goBack(); + navigation.state.params.fetchPost(); + } this.setState({ isPostSending: false }); clearTimeout(this.stateTimer); }, 500); From 4f57c748484ec04f3a41e5d9287d4204dc1aa177 Mon Sep 17 00:00:00 2001 From: feruz Date: Fri, 10 Jan 2020 05:22:06 +0200 Subject: [PATCH 2/5] alert title error to warning --- .../editorElements/tagInput/view/tagInputView.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/editorElements/tagInput/view/tagInputView.js b/src/components/editorElements/tagInput/view/tagInputView.js index fe8051a18..125168106 100644 --- a/src/components/editorElements/tagInput/view/tagInputView.js +++ b/src/components/editorElements/tagInput/view/tagInputView.js @@ -40,42 +40,42 @@ const TagInput = ({ if (handleTagChanged && cats.length > 0) { cats.length > 10 ? Alert.alert( - intl.formatMessage({ id: 'alert.error' }), + intl.formatMessage({ id: 'alert.warning' }), intl.formatMessage({ id: 'editor.limited_tags' }), ) : cats.find(c => c.length > 24) ? Alert.alert( - intl.formatMessage({ id: 'alert.error' }), + intl.formatMessage({ id: 'alert.warning' }), intl.formatMessage({ id: 'editor.limited_length' }), ) : cats.find(c => c.split('-').length > 2) ? Alert.alert( - intl.formatMessage({ id: 'alert.error' }), + intl.formatMessage({ id: 'alert.warning' }), intl.formatMessage({ id: 'editor.limited_dash' }), ) : cats.find(c => c.indexOf(',') >= 0) ? Alert.alert( - intl.formatMessage({ id: 'alert.error' }), + intl.formatMessage({ id: 'alert.warning' }), intl.formatMessage({ id: 'editor.limited_space' }), ) : cats.find(c => /[A-Z]/.test(c)) ? Alert.alert( - intl.formatMessage({ id: 'alert.error' }), + intl.formatMessage({ id: 'alert.warning' }), intl.formatMessage({ id: 'editor.limited_lowercase' }), ) : cats.find(c => !/^[a-z0-9-#]+$/.test(c)) ? Alert.alert( - intl.formatMessage({ id: 'alert.error' }), + intl.formatMessage({ id: 'alert.warning' }), intl.formatMessage({ id: 'editor.limited_characters' }), ) : cats.find(c => !/^[a-z-#]/.test(c)) ? Alert.alert( - intl.formatMessage({ id: 'alert.error' }), + intl.formatMessage({ id: 'alert.warning' }), intl.formatMessage({ id: 'editor.limited_firstchar' }), ) : cats.find(c => !/[a-z0-9]$/.test(c)) ? Alert.alert( - intl.formatMessage({ id: 'alert.error' }), + intl.formatMessage({ id: 'alert.warning' }), intl.formatMessage({ id: 'editor.limited_lastchar' }), ) : null; From 09c0b2531a18b38ae1414522c31a8b5213b6b75b Mon Sep 17 00:00:00 2001 From: feruz Date: Fri, 10 Jan 2020 06:27:44 +0200 Subject: [PATCH 3/5] taginput warning instant, replace alert with text --- .../tagInput/view/tagInputStyles.js | 5 ++ .../tagInput/view/tagInputView.js | 73 ++++++++++--------- src/screens/editor/screen/editorScreen.js | 3 +- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/components/editorElements/tagInput/view/tagInputStyles.js b/src/components/editorElements/tagInput/view/tagInputStyles.js index a65b422a8..1bf21d4a9 100644 --- a/src/components/editorElements/tagInput/view/tagInputStyles.js +++ b/src/components/editorElements/tagInput/view/tagInputStyles.js @@ -11,4 +11,9 @@ export default EStyleSheet.create({ borderBottomWidth: 1, borderBottomColor: '$primaryLightGray', }, + warning: { + color: '$primaryRed', + fontSize: 12, + fontFamily: '$editorFont', + }, }); diff --git a/src/components/editorElements/tagInput/view/tagInputView.js b/src/components/editorElements/tagInput/view/tagInputView.js index 125168106..d6cf6d1e6 100644 --- a/src/components/editorElements/tagInput/view/tagInputView.js +++ b/src/components/editorElements/tagInput/view/tagInputView.js @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { View, Alert } from 'react-native'; +import { View, Text } from 'react-native'; // Constants // Components @@ -20,6 +20,7 @@ const TagInput = ({ autoFocus, }) => { const [text, setText] = useState(''); + const [warning, setWarning] = useState(null); const [height, setHeight] = useState(0); useEffect(() => { @@ -33,52 +34,55 @@ const TagInput = ({ // Component Functions const _handleOnChange = _text => { setText(_text.replace(/,/g, ' ').replace(/#/g, '')); + + let cats = _text.split(' '); + if (handleTagChanged && cats.length > 0) { + cats.length > 10 + ? (setWarning(intl.formatMessage({ id: 'editor.limited_tags' })), setHeight(60)) + : cats.find(c => c.length > 24) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_length' })), setHeight(60)) + : cats.find(c => c.split('-').length > 2) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_dash' })), setHeight(60)) + : cats.find(c => c.indexOf(',') >= 0) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_space' })), setHeight(60)) + : cats.find(c => /[A-Z]/.test(c)) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_lowercase' })), setHeight(60)) + : cats.find(c => !/^[a-z0-9-#]+$/.test(c)) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_characters' })), setHeight(60)) + : cats.find(c => !/^[a-z-#]/.test(c)) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_firstchar' })), setHeight(60)) + : cats.find(c => !/[a-z0-9]$/.test(c)) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_lastchar' })), setHeight(60)) + : setWarning(null); + + handleTagChanged([...cats]); + } + + if (handleIsValid) { + handleIsValid(componentID, !!(_text && _text.length)); + } }; const _handleOnBlur = () => { if (onChange) { let cats = text.trim().split(' '); if (handleTagChanged && cats.length > 0) { cats.length > 10 - ? Alert.alert( - intl.formatMessage({ id: 'alert.warning' }), - intl.formatMessage({ id: 'editor.limited_tags' }), - ) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_tags' })), setHeight(60)) : cats.find(c => c.length > 24) - ? Alert.alert( - intl.formatMessage({ id: 'alert.warning' }), - intl.formatMessage({ id: 'editor.limited_length' }), - ) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_length' })), setHeight(60)) : cats.find(c => c.split('-').length > 2) - ? Alert.alert( - intl.formatMessage({ id: 'alert.warning' }), - intl.formatMessage({ id: 'editor.limited_dash' }), - ) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_dash' })), setHeight(60)) : cats.find(c => c.indexOf(',') >= 0) - ? Alert.alert( - intl.formatMessage({ id: 'alert.warning' }), - intl.formatMessage({ id: 'editor.limited_space' }), - ) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_space' })), setHeight(60)) : cats.find(c => /[A-Z]/.test(c)) - ? Alert.alert( - intl.formatMessage({ id: 'alert.warning' }), - intl.formatMessage({ id: 'editor.limited_lowercase' }), - ) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_lowercase' })), setHeight(60)) : cats.find(c => !/^[a-z0-9-#]+$/.test(c)) - ? Alert.alert( - intl.formatMessage({ id: 'alert.warning' }), - intl.formatMessage({ id: 'editor.limited_characters' }), - ) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_characters' })), setHeight(60)) : cats.find(c => !/^[a-z-#]/.test(c)) - ? Alert.alert( - intl.formatMessage({ id: 'alert.warning' }), - intl.formatMessage({ id: 'editor.limited_firstchar' }), - ) + ? (setWarning(intl.formatMessage({ id: 'editor.limited_firstchar' })), setHeight(60)) : cats.find(c => !/[a-z0-9]$/.test(c)) - ? Alert.alert( - intl.formatMessage({ id: 'alert.warning' }), - intl.formatMessage({ id: 'editor.limited_lastchar' }), - ) - : null; + ? (setWarning(intl.formatMessage({ id: 'editor.limited_lastchar' })), setHeight(60)) + : setWarning(null); handleTagChanged([...cats]); } onChange(text); @@ -108,6 +112,7 @@ const TagInput = ({ onBlur={() => _handleOnBlur()} value={text} /> + {warning && {warning}} ); }; diff --git a/src/screens/editor/screen/editorScreen.js b/src/screens/editor/screen/editorScreen.js index 4b57f0fb6..7cb61e954 100644 --- a/src/screens/editor/screen/editorScreen.js +++ b/src/screens/editor/screen/editorScreen.js @@ -167,10 +167,9 @@ class EditorScreen extends Component { _handleOnTagAdded = async tags => { const { fields: _fields } = this.state; - const _tags = tags.filter(tag => tag && tag !== ' '); + const _tags = tags; //.filter(tag => tag && tag !== ' '); const __tags = _tags.map(t => t.toLowerCase()); const __fields = { ..._fields, tags: [...__tags] }; - this.setState({ fields: __fields, isRemoveTag: false }, () => { this._handleFormUpdate('tag-area', __fields.tags); }); From f88b3bd50f37bcb7065056e62f6887949e68aeb5 Mon Sep 17 00:00:00 2001 From: feruz Date: Fri, 10 Jan 2020 07:04:24 +0200 Subject: [PATCH 4/5] handleIsValid removal, Form validity check for tags and title length --- .../editorElements/tagInput/view/tagInputView.js | 12 ++---------- src/screens/editor/screen/editorScreen.js | 4 +++- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/editorElements/tagInput/view/tagInputView.js b/src/components/editorElements/tagInput/view/tagInputView.js index d6cf6d1e6..02543ace8 100644 --- a/src/components/editorElements/tagInput/view/tagInputView.js +++ b/src/components/editorElements/tagInput/view/tagInputView.js @@ -12,7 +12,6 @@ import globalStyles from '../../../../globalStyles'; const TagInput = ({ value, onChange, - handleIsValid, componentID, handleTagChanged, intl, @@ -57,14 +56,11 @@ const TagInput = ({ handleTagChanged([...cats]); } - - if (handleIsValid) { - handleIsValid(componentID, !!(_text && _text.length)); - } }; const _handleOnBlur = () => { + let cats = []; if (onChange) { - let cats = text.trim().split(' '); + cats = text.trim().split(' '); if (handleTagChanged && cats.length > 0) { cats.length > 10 ? (setWarning(intl.formatMessage({ id: 'editor.limited_tags' })), setHeight(60)) @@ -87,10 +83,6 @@ const TagInput = ({ } onChange(text); } - - if (handleIsValid) { - handleIsValid(componentID, !!(text && text.length)); - } }; return ( diff --git a/src/screens/editor/screen/editorScreen.js b/src/screens/editor/screen/editorScreen.js index 7cb61e954..2fa607844 100644 --- a/src/screens/editor/screen/editorScreen.js +++ b/src/screens/editor/screen/editorScreen.js @@ -131,8 +131,10 @@ class EditorScreen extends Component { } else { isFormValid = get(fields, 'title', '') && + get(fields, 'title', '').length < 255 && (get(fields, 'body', '') || (bodyText && bodyText > 0)) && - get(fields, 'tags', null); + get(fields, 'tags', null) && + get(fields, 'tags', null).length < 10; } this.setState({ isFormValid }); From 0b0468419999ffd798b7a4e1ac95b0609b61bab3 Mon Sep 17 00:00:00 2001 From: feruz Date: Fri, 10 Jan 2020 08:49:47 +0200 Subject: [PATCH 5/5] try post renderer on comments --- .../postElements/body/view/commentBodyView.js | 146 +++++++++++++++++- 1 file changed, 144 insertions(+), 2 deletions(-) diff --git a/src/components/postElements/body/view/commentBodyView.js b/src/components/postElements/body/view/commentBodyView.js index 4a2189526..08c18775b 100644 --- a/src/components/postElements/body/view/commentBodyView.js +++ b/src/components/postElements/body/view/commentBodyView.js @@ -1,13 +1,20 @@ import React from 'react'; -import { Dimensions, Linking, Alert, TouchableOpacity, Text } from 'react-native'; +import { Dimensions, Linking, Alert, TouchableOpacity, Text, View } from 'react-native'; import { useIntl } from 'react-intl'; import HTML from '@esteemapp/react-native-render-html'; import { getParentsTagsRecursively } from '@esteemapp/react-native-render-html/src/HTMLUtils'; +import AutoHeightWebView from 'react-native-autoheight-webview'; +import EStyleSheet from 'react-native-extended-stylesheet'; +import get from 'lodash/get'; import { navigate } from '../../../../navigation/service'; // Constants import { default as ROUTES } from '../../../../constants/routeNames'; +import DEFAULT_IMAGE from '../../../../assets/no_image.png'; +import { CommentPlaceHolder } from '../../../basicUIElements'; +import script from './config'; + // Styles import styles from './postBodyStyles'; @@ -19,6 +26,7 @@ const CommentBody = ({ handleOnUserPress, handleOnPostPress, created, + commentDepth, }) => { const intl = useIntl(); @@ -146,6 +154,22 @@ const CommentBody = ({ ); } + if (passProps.parentWrapper === 'View') { + return ( + + ); + } return (