Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/MainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ class MainView extends React.Component<Props, State> {
feature={this.props.lightweightFeature || this.props.feature}
featureId={featureId}
mappingEvents={this.props.mappingEvents}
mappingEvent={this.props.mappingEvent}
equipmentInfo={this.props.equipmentInfo}
equipmentInfoId={equipmentInfoId}
categories={this.props.categories}
Expand Down
17 changes: 9 additions & 8 deletions src/components/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import includes from 'lodash/includes';
import isEqual from 'lodash/isEqual';
import * as React from 'react';
import { t } from 'ttag';
import { hrefForFeature } from '../../lib/Feature';
import { hrefForFeature, MappingEventFeature } from '../../lib/Feature';
import { currentLocales } from '../../lib/i18n';
import HighlightableMarker from './HighlightableMarker';
import LeafletLocateControl from './L.Control.Locate';
Expand All @@ -29,7 +29,7 @@ import {
} from '../../lib/Feature';
import { globalFetchManager } from '../../lib/FetchManager';
import goToLocationSettings from '../../lib/goToLocationSettings';
import { MappingEvents } from '../../lib/MappingEvent';
import { MappingEvent, MappingEvents } from '../../lib/MappingEvent';
import { normalizeCoordinate, normalizeCoordinates } from '../../lib/normalizeCoordinates';
import { hasOpenedLocationHelp, saveState } from '../../lib/savedState';
import shouldUseImperialUnits from '../../lib/shouldUseImperialUnits';
Expand Down Expand Up @@ -85,6 +85,7 @@ type Props = {
featureId?: string | number | null;
feature?: PotentialPromise<Feature | null>;
mappingEvents?: MappingEvents;
mappingEvent?: MappingEvent;
equipmentInfoId?: string | null;
equipmentInfo?: PotentialPromise<EquipmentInfo | null> | null;

Expand Down Expand Up @@ -132,8 +133,8 @@ type Props = {
type State = {
showZoomInfo?: boolean;
showLocationNotAllowedHint: boolean;
placeOrEquipment?: Feature | EquipmentInfo | null;
placeOrEquipmentPromise?: Promise<Feature | EquipmentInfo | null> | null;
placeOrEquipment?: Feature | EquipmentInfo | MappingEventFeature | null;
placeOrEquipmentPromise?: Promise<Feature | EquipmentInfo | MappingEventFeature | null> | null;
zoomedToFeatureId: string | null;
category: RootCategoryEntry | null;
};
Expand Down Expand Up @@ -251,9 +252,9 @@ export default class Map extends React.Component<Props, State> {
}

static getDerivedStateFromProps(props: Props, state: State): Partial<State> {
const { feature, equipmentInfo } = props;
const { feature, equipmentInfo, mappingEvent } = props;

const placeOrEquipment = equipmentInfo || feature;
const placeOrEquipment = equipmentInfo || feature || mappingEvent?.meetingPoint;

const category = props.categoryId ? Categories.getRootCategory(props.categoryId) : null;

Expand Down Expand Up @@ -480,8 +481,8 @@ export default class Map extends React.Component<Props, State> {
}

handlePromiseResolved(
placeOrEquipmentPromise: Promise<Feature | EquipmentInfo | null>,
placeOrEquipment: Feature | EquipmentInfo | null
placeOrEquipmentPromise: Promise<Feature | EquipmentInfo | MappingEventFeature | null>,
placeOrEquipment: Feature | EquipmentInfo | MappingEventFeature | null
) {
if (this.state.placeOrEquipmentPromise !== placeOrEquipmentPromise) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/components/MappingEvents/MappingEventToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ const MappingEventToolbar = ({

const hasMeetingPoint = Boolean(mappingEvent.meetingPoint);

const areaName = mappingEvent.area ? mappingEvent.area.properties.name : null;
const meetingPointName = mappingEvent.meetingPoint && mappingEvent.meetingPoint.properties.name;
const areaName = mappingEvent.area?.properties?.name;
const meetingPointName = mappingEvent.meetingPoint?.properties?.name;

// translator: Screenreader description for a mapping event
const toolbarAriaLabel = t`Mapping event ${mappingEvent.name}`;
Expand Down
17 changes: 8 additions & 9 deletions src/components/MappingEvents/MappingEventsToolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';
import { t } from 'ttag';
import styled from 'styled-components';
import FocusTrap from 'focus-trap-react';
import styled from 'styled-components';
import { t } from 'ttag';

import StyledToolbar from '../NodeToolbar/StyledToolbar';
import Link, { RouteConsumer } from '../Link/Link';
import { MappingEvents } from '../../lib/MappingEvent';
import { App } from '../../lib/App';
import StyledMarkdown from '../StyledMarkdown';
import { mappingEvent as MappingEventMarkerIcon } from '../icons/markers';
import { MappingEvents } from '../../lib/MappingEvent';
import colors from '../../lib/colors';
import CloseButton from '../CloseButton';
import Link, { RouteConsumer } from '../Link/Link';
import StyledToolbar from '../NodeToolbar/StyledToolbar';
import StyledMarkdown from '../StyledMarkdown';
import { mappingEvent as MappingEventMarkerIcon } from '../icons/markers';

type MappingEventsToolbarProps = {
app: App,
Expand Down Expand Up @@ -87,7 +86,7 @@ const MappingEventsToolbar = ({
</div>
<div>
<h3>{event.name}</h3>
{event.area && <p>{event.area.properties.name}</p>}
{event.area?.properties?.name && <p>{event.area?.properties?.name}</p>}
</div>
</Link>
);
Expand Down
1 change: 1 addition & 0 deletions src/lib/Feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export function getFeatureId(feature: Feature | EquipmentInfo | any): string | n
typeof feature._id === 'string' && feature._id,
properties && typeof properties.id === 'number' && properties.id,
properties && typeof properties._id === 'string' && properties._id,
properties && typeof properties.osm_id === 'number' && properties.osm_id,
];
const result = idProperties.filter(Boolean)[0];
return result ? String(result) : null;
Expand Down