@@ -55,7 +55,7 @@ export class Beacon extends TypedEventEmitter<Exclude<BeaconEvent, BeaconEvent.N
55
55
private _beaconInfo : BeaconInfoState ;
56
56
private _isLive : boolean ;
57
57
private livenessWatchTimeout : ReturnType < typeof setTimeout > ;
58
- private _latestLocationState : BeaconLocationState | undefined ;
58
+ private _latestLocationEvent : MatrixEvent | undefined ;
59
59
60
60
constructor (
61
61
private rootEvent : MatrixEvent ,
@@ -90,7 +90,11 @@ export class Beacon extends TypedEventEmitter<Exclude<BeaconEvent, BeaconEvent.N
90
90
}
91
91
92
92
public get latestLocationState ( ) : BeaconLocationState | undefined {
93
- return this . _latestLocationState ;
93
+ return this . _latestLocationEvent && parseBeaconContent ( this . _latestLocationEvent . getContent ( ) ) ;
94
+ }
95
+
96
+ public get latestLocationEvent ( ) : MatrixEvent | undefined {
97
+ return this . _latestLocationEvent ;
94
98
}
95
99
96
100
public update ( beaconInfoEvent : MatrixEvent ) : void {
@@ -168,13 +172,13 @@ export class Beacon extends TypedEventEmitter<Exclude<BeaconEvent, BeaconEvent.N
168
172
const latestLocationEvent = validLocationEvents . sort ( sortEventsByLatestContentTimestamp ) ?. [ 0 ] ;
169
173
170
174
if ( latestLocationEvent ) {
171
- this . _latestLocationState = parseBeaconContent ( latestLocationEvent . getContent ( ) ) ;
175
+ this . _latestLocationEvent = latestLocationEvent ;
172
176
this . emit ( BeaconEvent . LocationUpdate , this . latestLocationState ) ;
173
177
}
174
178
}
175
179
176
180
private clearLatestLocation = ( ) => {
177
- this . _latestLocationState = undefined ;
181
+ this . _latestLocationEvent = undefined ;
178
182
this . emit ( BeaconEvent . LocationUpdate , this . latestLocationState ) ;
179
183
} ;
180
184
0 commit comments