Remove "no file" error dialog

Summary:
This is a programming error, not something that users
should ever be exposed to. This logs an error instead
and just doesn't show anything.

The big benefit is that the component no longer
needs to deal with `file` potentially being undefined.

Reviewed By: jknoxville

Differential Revision: D17786913

fbshipit-source-id: 32a357381e64cd9237ad4a0112c346d7121634ef
This commit is contained in:
Pascal Hartig
2019-10-08 00:17:23 -07:00
committed by Facebook Github Bot
parent 36abf6e38c
commit ca8df6d680
2 changed files with 8 additions and 26 deletions

View File

@@ -97,16 +97,17 @@ export class App extends React.Component<Props> {
<ShareSheetExportUrl onHide={onHide} logger={this.props.logger} />
);
case ACTIVE_SHEET_SHARE_DATA_IN_FILE:
return (
return this.props.share && this.props.share.type === 'file' ? (
<ShareSheetExportFile
onHide={onHide}
file={
this.props.share && this.props.share.type === 'file'
? this.props.share.file
: null
}
file={this.props.share.file}
logger={this.props.logger}
/>
) : (
(() => {
console.error('No file provided when calling share sheet.');
return null;
})()
);
case ACTIVE_SHEET_PLUGIN_SHEET:
// Currently unused.

View File

@@ -50,7 +50,7 @@ const InfoText = styled(Text)({
type Props = {
onHide: () => void;
file: string | null;
file: string;
logger: Logger;
};
@@ -202,9 +202,6 @@ export default class ShareSheetExportFile extends Component<Props, State> {
}
render() {
if (!this.props.file) {
return this.renderNoFileError(this.context);
}
const {result, statusUpdate} = this.state;
switch (result.kind) {
case 'success':
@@ -215,20 +212,4 @@ export default class ShareSheetExportFile extends Component<Props, State> {
return this.renderPending(this.context, statusUpdate);
}
}
renderNoFileError(context: any) {
return (
<Container>
<Center>
<Title bold>No file selected</Title>
</Center>
<FlexRow>
<Spacer />
<Button compact padded onClick={() => this.cancelAndHide(context)}>
Close
</Button>
</FlexRow>
</Container>
);
}
}