@@ -55,7 +55,7 @@ export class Beacon extends TypedEventEmitter<Exclude<BeaconEvent, BeaconEvent.N
5555 private _beaconInfo : BeaconInfoState ;
5656 private _isLive : boolean ;
5757 private livenessWatchTimeout : ReturnType < typeof setTimeout > ;
58- private _latestLocationState : BeaconLocationState | undefined ;
58+ private _latestLocationEvent : MatrixEvent | undefined ;
5959
6060 constructor (
6161 private rootEvent : MatrixEvent ,
@@ -90,7 +90,11 @@ export class Beacon extends TypedEventEmitter<Exclude<BeaconEvent, BeaconEvent.N
9090 }
9191
9292 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 ;
9498 }
9599
96100 public update ( beaconInfoEvent : MatrixEvent ) : void {
@@ -168,13 +172,13 @@ export class Beacon extends TypedEventEmitter<Exclude<BeaconEvent, BeaconEvent.N
168172 const latestLocationEvent = validLocationEvents . sort ( sortEventsByLatestContentTimestamp ) ?. [ 0 ] ;
169173
170174 if ( latestLocationEvent ) {
171- this . _latestLocationState = parseBeaconContent ( latestLocationEvent . getContent ( ) ) ;
175+ this . _latestLocationEvent = latestLocationEvent ;
172176 this . emit ( BeaconEvent . LocationUpdate , this . latestLocationState ) ;
173177 }
174178 }
175179
176180 private clearLatestLocation = ( ) => {
177- this . _latestLocationState = undefined ;
181+ this . _latestLocationEvent = undefined ;
178182 this . emit ( BeaconEvent . LocationUpdate , this . latestLocationState ) ;
179183 } ;
180184
0 commit comments