Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 47cbef2

Browse files
authored
Ensure maps show up in replies and threads, by creating unique IDs (#7568)
1 parent e1cdbe1 commit 47cbef2

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/components/views/messages/MLocationBody.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,18 @@ interface IState {
3838
@replaceableComponent("views.messages.MLocationBody")
3939
export default class MLocationBody extends React.Component<IBodyProps, IState> {
4040
private coords: GeolocationCoordinates;
41+
private bodyId: string;
42+
private markerId: string;
4143

4244
constructor(props: IBodyProps) {
4345
super(props);
4446

47+
const randomString = Math.random().toString(16).slice(2, 10);
48+
const idSuffix = `${props.mxEvent.getId()}_${randomString}`;
49+
this.bodyId = `mx_MLocationBody_${idSuffix}`;
50+
this.markerId = `mx_MLocationBody_marker_${idSuffix}`;
4551
this.coords = parseGeoUri(locationEventGeoUri(this.props.mxEvent));
52+
4653
this.state = {
4754
error: undefined,
4855
};
@@ -56,20 +63,12 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
5663
createMap(
5764
this.coords,
5865
false,
59-
this.getBodyId(),
60-
this.getMarkerId(),
66+
this.bodyId,
67+
this.markerId,
6168
(e: Error) => this.setState({ error: e }),
6269
);
6370
}
6471

65-
private getBodyId = () => {
66-
return `mx_MLocationBody_${this.props.mxEvent.getId()}`;
67-
};
68-
69-
private getMarkerId = () => {
70-
return `mx_MLocationBody_marker_${this.props.mxEvent.getId()}`;
71-
};
72-
7372
private onClick = (
7473
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
7574
) => {
@@ -93,8 +92,8 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
9392
render(): React.ReactElement<HTMLDivElement> {
9493
return <LocationBodyContent
9594
mxEvent={this.props.mxEvent}
96-
bodyId={this.getBodyId()}
97-
markerId={this.getMarkerId()}
95+
bodyId={this.bodyId}
96+
markerId={this.markerId}
9897
error={this.state.error}
9998
tooltip={_t("Expand map")}
10099
onClick={this.onClick}

0 commit comments

Comments
 (0)