Skip to content

Commit

Permalink
Handle null marker in left sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
starsep committed Dec 24, 2023
1 parent 7f18d0c commit 06b1de7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const Map: FC<MapProps> = ({ openChangesetId, setOpenChangesetId }) => {

return (
<>
{ sidebarLeftShown && marker !== null && (
{ sidebarLeftShown && (
<SidebarLeft
action={sidebarAction}
data={sidebarData}
Expand Down
6 changes: 5 additions & 1 deletion src/components/sidebar-left.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const SidebarLeft: FC<SidebarLeftProps> = (props) => {
case SidebarAction.showDetails:
return <DefibrillatorDetails data={data} closeSidebar={closeSidebar} />;
case SidebarAction.addNode:
if (marker === null) {
console.error("Marker shouldn't be null");
return null;
}
return (
<DefibrillatorEditor
closeSidebar={closeSidebar}
Expand Down Expand Up @@ -60,7 +64,7 @@ interface SidebarLeftProps {
data: DefibrillatorData | null,
closeSidebar: () => void,
visible: boolean,
marker: Marker,
marker: Marker | null,
openChangesetId: string,
setOpenChangesetId: (changesetId: string) => void,
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/sidebar/defibrillatorEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const DefibrillatorEditor: FC<DefibrillatorEditorProps> = ({
});
};
if (newAED) {
if (marker === null) {
console.error("Marker shouldn't be null");
return null;
}
const lngLat = marker.getLngLat();
const newDefibrillatorData = {
lon: lngLat.lng,
Expand Down Expand Up @@ -135,7 +139,7 @@ const DefibrillatorEditor: FC<DefibrillatorEditorProps> = ({

interface DefibrillatorEditorProps {
closeSidebar: () => void,
marker: Marker,
marker: Marker | null,
openChangesetId: string,
setOpenChangesetId: (changesetId: string) => void,
data: DefibrillatorData | null,
Expand Down

0 comments on commit 06b1de7

Please sign in to comment.