mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 04:11:50 +03:00
Merge pull request #629 from esteemapp/editor/publish
fixed editor publish issue
This commit is contained in:
commit
9e64f8a588
@ -58,6 +58,23 @@ export default class MarkdownEditorView extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const { text } = this.state;
|
||||
const { isFormValid, handleIsFormValid } = this.props;
|
||||
|
||||
if (prevState.text !== text && !isFormValid) {
|
||||
const nextText = text.replace(prevState.text, '');
|
||||
|
||||
if (nextText && nextText.length > 0) {
|
||||
this._changeText(text);
|
||||
|
||||
if (handleIsFormValid) {
|
||||
handleIsFormValid(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Component functions
|
||||
_changeText = (input) => {
|
||||
const {
|
||||
@ -147,7 +164,7 @@ export default class MarkdownEditorView extends Component {
|
||||
iconType="FontAwesome"
|
||||
name="image"
|
||||
/>
|
||||
{/* <View style={styles.clearButtonWrapper}>
|
||||
<View style={styles.clearButtonWrapper}>
|
||||
<IconButton
|
||||
onPress={() => this.ClearActionSheet.show()}
|
||||
size={20}
|
||||
@ -155,7 +172,7 @@ export default class MarkdownEditorView extends Component {
|
||||
iconType="FontAwesome"
|
||||
name="trash"
|
||||
/>
|
||||
</View> */}
|
||||
</View>
|
||||
{/* TODO: After alpha */}
|
||||
{/* <DropdownButton
|
||||
style={styles.dropdownStyle}
|
||||
|
@ -39,7 +39,7 @@ class EditorScreen extends Component {
|
||||
|
||||
// Component Life Cycles
|
||||
componentWillReceiveProps = (nextProps) => {
|
||||
const { draftPost } = this.props;
|
||||
const { draftPost, isUploading } = this.props;
|
||||
|
||||
if (nextProps.draftPost && draftPost !== nextProps.draftPost) {
|
||||
this.setState({
|
||||
@ -48,6 +48,10 @@ class EditorScreen extends Component {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (isUploading !== nextProps) {
|
||||
this._handleFormUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
// Component Functions
|
||||
@ -107,7 +111,7 @@ class EditorScreen extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_handleIsFormValid = () => {
|
||||
_handleIsFormValid = (bodyText) => {
|
||||
const { fields } = this.state;
|
||||
const { isReply } = this.props;
|
||||
let _isFormValid;
|
||||
@ -118,9 +122,8 @@ class EditorScreen extends Component {
|
||||
_isFormValid = fields
|
||||
&& fields.title
|
||||
&& fields.title.length > 0
|
||||
&& fields.body
|
||||
&& fields.body.length > 0
|
||||
&& fields.tags.length > 0;
|
||||
&& ((fields.body && fields.body.length > 0 && fields.tags.length > 0)
|
||||
|| (bodyText && bodyText.length > 0));
|
||||
}
|
||||
|
||||
this.setState({ isFormValid: _isFormValid });
|
||||
@ -215,6 +218,9 @@ class EditorScreen extends Component {
|
||||
componentID="body"
|
||||
draftBody={fields && fields.body}
|
||||
handleOnTextChange={this._setWordsCount}
|
||||
handleFormUpdate={this._handleFormUpdate}
|
||||
handleIsFormValid={this._handleIsFormValid}
|
||||
isFormValid={isFormValid}
|
||||
handleOpenImagePicker={handleOnImagePicker}
|
||||
intl={intl}
|
||||
uploadedImage={uploadedImage}
|
||||
|
Loading…
Reference in New Issue
Block a user