mirror of https://github.com/vector-im/riot-web
Ensure maps show up in replies and threads, by creating unique IDs (#7568)
parent
e1cdbe1e54
commit
47cbef2af2
|
@ -38,11 +38,18 @@ interface IState {
|
||||||
@replaceableComponent("views.messages.MLocationBody")
|
@replaceableComponent("views.messages.MLocationBody")
|
||||||
export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
||||||
private coords: GeolocationCoordinates;
|
private coords: GeolocationCoordinates;
|
||||||
|
private bodyId: string;
|
||||||
|
private markerId: string;
|
||||||
|
|
||||||
constructor(props: IBodyProps) {
|
constructor(props: IBodyProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
const randomString = Math.random().toString(16).slice(2, 10);
|
||||||
|
const idSuffix = `${props.mxEvent.getId()}_${randomString}`;
|
||||||
|
this.bodyId = `mx_MLocationBody_${idSuffix}`;
|
||||||
|
this.markerId = `mx_MLocationBody_marker_${idSuffix}`;
|
||||||
this.coords = parseGeoUri(locationEventGeoUri(this.props.mxEvent));
|
this.coords = parseGeoUri(locationEventGeoUri(this.props.mxEvent));
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
error: undefined,
|
error: undefined,
|
||||||
};
|
};
|
||||||
|
@ -56,20 +63,12 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
||||||
createMap(
|
createMap(
|
||||||
this.coords,
|
this.coords,
|
||||||
false,
|
false,
|
||||||
this.getBodyId(),
|
this.bodyId,
|
||||||
this.getMarkerId(),
|
this.markerId,
|
||||||
(e: Error) => this.setState({ error: e }),
|
(e: Error) => this.setState({ error: e }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getBodyId = () => {
|
|
||||||
return `mx_MLocationBody_${this.props.mxEvent.getId()}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
private getMarkerId = () => {
|
|
||||||
return `mx_MLocationBody_marker_${this.props.mxEvent.getId()}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
private onClick = (
|
private onClick = (
|
||||||
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
||||||
) => {
|
) => {
|
||||||
|
@ -93,8 +92,8 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
|
||||||
render(): React.ReactElement<HTMLDivElement> {
|
render(): React.ReactElement<HTMLDivElement> {
|
||||||
return <LocationBodyContent
|
return <LocationBodyContent
|
||||||
mxEvent={this.props.mxEvent}
|
mxEvent={this.props.mxEvent}
|
||||||
bodyId={this.getBodyId()}
|
bodyId={this.bodyId}
|
||||||
markerId={this.getMarkerId()}
|
markerId={this.markerId}
|
||||||
error={this.state.error}
|
error={this.state.error}
|
||||||
tooltip={_t("Expand map")}
|
tooltip={_t("Expand map")}
|
||||||
onClick={this.onClick}
|
onClick={this.onClick}
|
||||||
|
|
Loading…
Reference in New Issue