RN-248 Upload file and leave channel (#759)

* RN-248 Upload file and leave channel

* Fix bool to string comparison
This commit is contained in:
Chris Duarte 2017-07-21 06:49:30 -07:00 committed by enahum
parent 374dccd770
commit aafc8001dc
2 changed files with 17 additions and 4 deletions

View file

@ -12,7 +12,6 @@ import {
View
} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
import {RequestStatus} from 'mattermost-redux/constants';
import FileAttachmentImage from 'app/components/file_attachment_list/file_attachment_image';
import FileAttachmentIcon from 'app/components/file_attachment_list/file_attachment_icon';
@ -35,7 +34,7 @@ export default class FileUploadPreview extends PureComponent {
inputHeight: PropTypes.number.isRequired,
rootId: PropTypes.string,
theme: PropTypes.object.isRequired,
uploadFileRequestStatus: PropTypes.string.isRequired
filesUploadingForCurrentChannel: PropTypes.bool.isRequired
};
handleRetryFileUpload = (file) => {
@ -102,7 +101,7 @@ export default class FileUploadPreview extends PureComponent {
}
render() {
if (this.props.channelIsLoading || (!this.props.files.length && this.props.uploadFileRequestStatus !== RequestStatus.STARTED)) {
if (this.props.channelIsLoading || (!this.props.files.length && !this.props.filesUploadingForCurrentChannel)) {
return null;
}

View file

@ -3,6 +3,7 @@
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {createSelector} from 'reselect';
import {handleRemoveFile, retryFileUpload} from 'app/actions/views/file_upload';
import {addFileToFetchCache} from 'app/actions/views/file_preview';
@ -10,13 +11,26 @@ import {getTheme} from 'app/selectors/preferences';
import FileUploadPreview from './file_upload_preview';
const checkForFileUploadingInChannel = createSelector(
(state, channelId, rootId) => {
if (rootId) {
return state.views.thread.drafts[rootId];
}
return state.views.channel.drafts[channelId];
},
(draft) => {
return draft.files.some((f) => f.loading);
}
);
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,
filesUploadingForCurrentChannel: checkForFileUploadingInChannel(state, ownProps.channelId, ownProps.rootId),
theme: getTheme(state)
};
}