Skip to content

Commit

Permalink
feat: remove deprecated event types
Browse files Browse the repository at this point in the history
  • Loading branch information
KiwiKilian committed Dec 8, 2024
1 parent 3bae330 commit 315ea96
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 75 deletions.
29 changes: 5 additions & 24 deletions src/components/ShapeSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
type ExpressionField,
type FilterExpression,
} from "../utils/MapLibreRNStyles";
import { copyPropertiesAsDeprecated } from "../utils/deprecation";
import { getFilter } from "../utils/filterUtils";

const MapLibreRN = NativeModules.MLRNModule;
Expand Down Expand Up @@ -323,31 +322,13 @@ const ShapeSource = memo(
payload: { features, coordinates, point },
},
} = event;
let newEvent = {
features,
coordinates,
point,
};
newEvent = copyPropertiesAsDeprecated(
event,
newEvent,
(key: string): void => {
console.warn(
`event.${key} is deprecated on ShapeSource#onPress, please use event.features`,
);
},
{
nativeEvent: (
origNativeEvent: NativeSyntheticEvent<{ payload: OnPressEvent }>,
) => ({
...origNativeEvent,
payload: features[0],
}),
},
);

if (props.onPress) {
props.onPress(newEvent);
props.onPress({
features,
coordinates,
point,
});
}
}

Expand Down
24 changes: 4 additions & 20 deletions src/components/VectorSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { type BaseProps } from "../types/BaseProps";
import { type OnPressEvent } from "../types/OnPressEvent";
import { cloneReactChildrenWithProps, isFunction, isAndroid } from "../utils";
import { type FilterExpression } from "../utils/MapLibreRNStyles";
import { copyPropertiesAsDeprecated } from "../utils/deprecation";
import { getFilter } from "../utils/filterUtils";

const MapLibreRN = NativeModules.MLRNModule;
Expand Down Expand Up @@ -160,33 +159,18 @@ const VectorSource = memo(
if (!onPress) {
return;
}

const {
nativeEvent: {
payload: { features, coordinates, point },
},
} = event;
let newEvent = {

onPress({
features,
coordinates,
point,
};
newEvent = copyPropertiesAsDeprecated(
event,
newEvent,
(key: string) => {
console.warn(
`event.${key} is deprecated on VectorSource#onPress, please use event.features`,
);
},
{
nativeEvent: (origNativeEvent: OnPressEvent) => ({
...origNativeEvent,
payload: features[0],
}),
},
);

onPress(newEvent);
});
};

const allProps = {
Expand Down
31 changes: 0 additions & 31 deletions src/utils/deprecation.ts

This file was deleted.

0 comments on commit 315ea96

Please sign in to comment.