@@ -38,11 +38,18 @@ interface IState {
38
38
@replaceableComponent ( "views.messages.MLocationBody" )
39
39
export default class MLocationBody extends React . Component < IBodyProps , IState > {
40
40
private coords : GeolocationCoordinates ;
41
+ private bodyId : string ;
42
+ private markerId : string ;
41
43
42
44
constructor ( props : IBodyProps ) {
43
45
super ( props ) ;
44
46
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 } ` ;
45
51
this . coords = parseGeoUri ( locationEventGeoUri ( this . props . mxEvent ) ) ;
52
+
46
53
this . state = {
47
54
error : undefined ,
48
55
} ;
@@ -56,20 +63,12 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
56
63
createMap (
57
64
this . coords ,
58
65
false ,
59
- this . getBodyId ( ) ,
60
- this . getMarkerId ( ) ,
66
+ this . bodyId ,
67
+ this . markerId ,
61
68
( e : Error ) => this . setState ( { error : e } ) ,
62
69
) ;
63
70
}
64
71
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
-
73
72
private onClick = (
74
73
event : React . MouseEvent < HTMLDivElement , MouseEvent > ,
75
74
) => {
@@ -93,8 +92,8 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
93
92
render ( ) : React . ReactElement < HTMLDivElement > {
94
93
return < LocationBodyContent
95
94
mxEvent = { this . props . mxEvent }
96
- bodyId = { this . getBodyId ( ) }
97
- markerId = { this . getMarkerId ( ) }
95
+ bodyId = { this . bodyId }
96
+ markerId = { this . markerId }
98
97
error = { this . state . error }
99
98
tooltip = { _t ( "Expand map" ) }
100
99
onClick = { this . onClick }
0 commit comments