PLT-6145 RN: File upload overlay doesn't clear (#437)

This commit is contained in:
Chris Duarte 2017-03-30 19:46:20 -07:00 committed by enahum
parent 422474a0d2
commit ae3de5c1f2
6 changed files with 17 additions and 5 deletions

View file

@ -26,6 +26,7 @@ export default class FileUploadPreview extends PureComponent {
handleRemoveFile: PropTypes.func.isRequired
}).isRequired,
channelId: PropTypes.string.isRequired,
channelIsLoading: PropTypes.bool,
createPostRequestStatus: PropTypes.string.isRequired,
fetchCache: PropTypes.object.isRequired,
files: PropTypes.array.isRequired,
@ -70,7 +71,7 @@ export default class FileUploadPreview extends PureComponent {
}
render() {
if (!this.props.files.length && this.props.uploadFileRequestStatus !== RequestStatus.STARTED) {
if (this.props.channelIsLoading || (!this.props.files.length && this.props.uploadFileRequestStatus !== RequestStatus.STARTED)) {
return null;
}

View file

@ -13,6 +13,7 @@ import FileUploadPreview from './file_upload_preview';
function mapStateToProps(state, ownProps) {
return {
...ownProps,
channelIsLoading: state.views.channel.loading,
createPostRequestStatus: state.requests.posts.createPost.status,
fetchCache: state.views.fetchCache,
uploadFileRequestStatus: state.requests.files.uploadFiles.status,

View file

@ -26,6 +26,7 @@ const MAX_CONTENT_HEIGHT = 100;
export default class PostTextbox extends PureComponent {
static propTypes = {
channelIsLoading: PropTypes.bool.isRequired,
currentUserId: PropTypes.string.isRequired,
typing: PropTypes.array.isRequired,
teamId: PropTypes.string.isRequired,
@ -238,11 +239,13 @@ export default class PostTextbox extends PureComponent {
};
render() {
const {theme} = this.props;
const {channelIsLoading, theme, value} = this.props;
const style = getStyleSheet(theme);
const textInputHeight = Math.min(this.state.contentHeight, MAX_CONTENT_HEIGHT);
const textValue = channelIsLoading ? '' : value;
let placeholder;
if (this.props.rootId) {
placeholder = {id: 'create_comment.addComment', defaultMessage: 'Add a comment...'};
@ -290,7 +293,7 @@ export default class PostTextbox extends PureComponent {
<View style={style.inputContainer}>
<TextInputWithLocalizedPlaceholder
ref='input'
value={this.props.value}
value={textValue}
onChangeText={this.handleTextChange}
onSelectionChange={this.handleSelectionChange}
onContentSizeChange={this.handleContentSizeChange}

View file

@ -17,6 +17,7 @@ import PostTextbox from './post_textbox';
function mapStateToProps(state, ownProps) {
return {
...ownProps,
channelIsLoading: state.views.channel.loading,
currentUserId: getCurrentUserId(state),
typing: getUsersTyping(state),
theme: getTheme(state),

View file

@ -130,6 +130,12 @@ export default class ImagePreview extends PureComponent {
}
}
handleClose = () => {
if (this.state.showFileInfo) {
this.props.actions.goBack();
}
}
handleImageTap = () => {
/*if (!this.lastPress) {
this.lastPress = Date.now();
@ -268,7 +274,7 @@ export default class ImagePreview extends PureComponent {
<View style={style.header}>
<View style={style.headerControls}>
<TouchableOpacity
onPress={this.props.actions.goBack}
onPress={this.handleClose}
style={style.headerIcon}
>
<Icon

View file

@ -26,7 +26,7 @@ export default class LoadTeam extends PureComponent {
static navigationProps = {
renderBackButton: () => null,
renderTitleComponent: () => <View style={{flex: 1, backgroundColor: 'blue'}}/>
renderTitleComponent: () => null
}
componentDidMount() {