Skip to content

Commit a2572c2

Browse files
committed
moved Dropzone's onDrop handler to AppToolbar
1 parent d606781 commit a2572c2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/components/App.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -884,11 +884,9 @@ export default class App extends React.Component<any, AppState> {
884884
});
885885
}
886886

887-
onFileSelected = (e: File[]) => {
888-
const file = e[0];
889-
const pmt = new PMTiles(new FileSource(file));
887+
onLocalPMTilesSelected = (file: File) => {
890888
this.setState({
891-
localPMTiles: pmt
889+
localPMTiles: new PMTiles(new FileSource(file))
892890
})
893891
}
894892

@@ -906,7 +904,7 @@ export default class App extends React.Component<any, AppState> {
906904
onStyleOpen={this.onStyleChanged}
907905
onSetMapState={this.setMapState}
908906
onToggleModal={this.toggleModal.bind(this)}
909-
onFileSelected={this.onFileSelected}
907+
onLocalPMTilesSelected={this.onLocalPMTilesSelected}
910908
/>
911909

912910
const layerList = <LayerList

src/components/AppToolbar.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type AppToolbarInternalProps = {
105105
onSetMapState(mapState: MapState): unknown
106106
mapState?: MapState
107107
renderer?: string
108-
onFileSelected(...args: unknown[]): unknown
108+
onLocalPMTilesSelected(file: File): unknown
109109
} & WithTranslation;
110110

111111
class AppToolbarInternal extends React.Component<AppToolbarInternalProps> {
@@ -137,6 +137,11 @@ class AppToolbarInternal extends React.Component<AppToolbarInternalProps> {
137137
}
138138
}
139139

140+
onFileSelected = (e: File[]) => {
141+
const file = e[0];
142+
this.props.onLocalPMTilesSelected(file);
143+
}
144+
140145
render() {
141146
const t = this.props.t;
142147
const views = [
@@ -293,7 +298,7 @@ class AppToolbarInternal extends React.Component<AppToolbarInternalProps> {
293298
<IconText>{t("Help")}</IconText>
294299
</ToolbarLink>
295300

296-
<Dropzone onDrop={this.props.onFileSelected}>
301+
<Dropzone onDrop={this.onFileSelected}>
297302
{({getRootProps, getInputProps}) => (
298303
<div {...getRootProps({className: 'dropzone maputnik-toolbar-link'})}>
299304
<input {...getInputProps()} />

0 commit comments

Comments
 (0)