update location event types (#8022)

* update types

Signed-off-by: Kerry Archibald <kerrya@element.io>

* fix tests

Signed-off-by: Kerry Archibald <kerrya@element.io>

* lint

Signed-off-by: Kerry Archibald <kerrya@element.io>

* trigger

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry 2022-03-10 19:03:31 +01:00 committed by GitHub
parent a4b2e0c0d8
commit e96d9157a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 39 additions and 35 deletions

View file

@ -19,10 +19,10 @@ import maplibregl from 'maplibre-gl';
import { logger } from "matrix-js-sdk/src/logger";
import { MatrixEvent } from 'matrix-js-sdk/src/models/event';
import {
ASSET_NODE_TYPE,
M_ASSET,
LocationAssetType,
ILocationContent,
LOCATION_EVENT_TYPE,
M_LOCATION,
} from 'matrix-js-sdk/src/@types/location';
import { ClientEvent, IClientWellKnown } from 'matrix-js-sdk/src/client';
@ -129,7 +129,7 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
}
export function isSelfLocation(locationContent: ILocationContent): boolean {
const asset = ASSET_NODE_TYPE.findIn(locationContent) as { type: string };
const asset = M_ASSET.findIn(locationContent) as { type: string };
const assetType = asset?.type ?? LocationAssetType.Self;
return assetType == LocationAssetType.Self;
}
@ -298,7 +298,7 @@ export function locationEventGeoUri(mxEvent: MatrixEvent): string {
// events - so folks can read their old chat history correctly.
// https://github.com/matrix-org/matrix-doc/issues/3516
const content = mxEvent.getContent();
const loc = LOCATION_EVENT_TYPE.findIn(content) as { uri?: string };
const loc = M_LOCATION.findIn(content) as { uri?: string };
return loc ? loc.uri : content['geo_uri'];
}
@ -343,7 +343,7 @@ function makeLink(coords: GeolocationCoordinates): string {
export function createMapSiteLink(event: MatrixEvent): string {
const content: Object = event.getContent();
const mLocation = content[LOCATION_EVENT_TYPE.name];
const mLocation = content[M_LOCATION.name];
if (mLocation !== undefined) {
const uri = mLocation["uri"];
if (uri !== undefined) {