Refactor share sheet selection
Summary: We're if-ing over an enum, so this should be a switch. Also removed the edge case for the share sheet and made the error handling part of the component so the user actually sees it. Reviewed By: jknoxville Differential Revision: D15853056 fbshipit-source-id: 241ed0f2e042b08c4c157db9616175297b683ac3
This commit is contained in:
committed by
Facebook Github Bot
parent
5aaf0c4f29
commit
9c75ea7665
@@ -65,7 +65,7 @@ const Padder = styled('div')(
|
||||
|
||||
type Props = {
|
||||
onHide: () => mixed,
|
||||
file: string,
|
||||
file: ?string,
|
||||
};
|
||||
type State = {
|
||||
errorArray: Array<Error>,
|
||||
@@ -86,6 +86,10 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
||||
};
|
||||
|
||||
async componentDidMount() {
|
||||
if (!this.props.file) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const {errorArray} = await reportPlatformFailures(
|
||||
exportStoreToFile(this.props.file, this.context.store),
|
||||
@@ -98,6 +102,10 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.props.file) {
|
||||
return this.renderNoFileError();
|
||||
}
|
||||
|
||||
const {result} = this.state;
|
||||
if (result) {
|
||||
const {success, error} = result;
|
||||
@@ -161,4 +169,20 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
renderNoFileError() {
|
||||
return (
|
||||
<Container>
|
||||
<Center>
|
||||
<Title bold>No file selected</Title>
|
||||
</Center>
|
||||
<FlexRow>
|
||||
<Spacer />
|
||||
<Button compact padded onClick={this.props.onHide}>
|
||||
Close
|
||||
</Button>
|
||||
</FlexRow>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user