RN-238 Fix ability to post with just images (#672)
* Fix ability to post with just images * Feedback review
This commit is contained in:
parent
675eca630c
commit
cb8d7799a8
1 changed files with 11 additions and 12 deletions
|
|
@ -64,7 +64,6 @@ class PostTextbox extends PureComponent {
|
|||
super(props);
|
||||
|
||||
this.state = {
|
||||
canSend: false,
|
||||
contentHeight: INITIAL_HEIGHT,
|
||||
inputWidth: null
|
||||
};
|
||||
|
|
@ -79,7 +78,7 @@ class PostTextbox extends PureComponent {
|
|||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const {intl} = this.props;
|
||||
const {files, uploadFileRequestStatus, value} = nextProps;
|
||||
const {value} = nextProps;
|
||||
const valueLength = value.trim().length;
|
||||
|
||||
if (valueLength > MAX_MESSAGE_LENGTH) {
|
||||
|
|
@ -97,14 +96,6 @@ class PostTextbox extends PureComponent {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
const canSend =
|
||||
(valueLength > 0 && valueLength <= MAX_MESSAGE_LENGTH) &&
|
||||
files.filter((f) => !f.failed).length === 0 &&
|
||||
uploadFileRequestStatus !== RequestStatus.STARTED;
|
||||
this.setState({
|
||||
canSend
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
|
@ -118,6 +109,14 @@ class PostTextbox extends PureComponent {
|
|||
this.refs.input.blur();
|
||||
};
|
||||
|
||||
canSend = () => {
|
||||
const {files, uploadFileRequestStatus, value} = this.props;
|
||||
const valueLength = value.trim().length;
|
||||
|
||||
return (valueLength > 0 && valueLength <= MAX_MESSAGE_LENGTH) ||
|
||||
(files.filter((f) => !f.failed).length > 0 && uploadFileRequestStatus !== RequestStatus.STARTED);
|
||||
};
|
||||
|
||||
handleAndroidKeyboard = () => {
|
||||
this.blur();
|
||||
};
|
||||
|
|
@ -132,7 +131,7 @@ class PostTextbox extends PureComponent {
|
|||
};
|
||||
|
||||
handleSendMessage = () => {
|
||||
if (!this.state.canSend) {
|
||||
if (!this.canSend()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -453,7 +452,7 @@ class PostTextbox extends PureComponent {
|
|||
style={[style.input, {height: textInputHeight}]}
|
||||
onLayout={this.handleInputSizeChange}
|
||||
/>
|
||||
{this.state.canSend &&
|
||||
{this.canSend() &&
|
||||
<TouchableOpacity
|
||||
onPress={this.handleSendMessage}
|
||||
style={style.sendButton}
|
||||
|
|
|
|||
Loading…
Reference in a new issue