Skip to content

Commit

Permalink
default beacon info asset type to self
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry Archibald committed Aug 15, 2022
1 parent 251f32c commit c0d0ab6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/content-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,16 @@ export type BeaconInfoState = MBeaconInfoContent & {
*/
export const parseBeaconInfoContent = (content: MBeaconInfoEventContent): BeaconInfoState => {
const { description, timeout, live } = content;
const asset = M_ASSET.findIn<MAssetContent>(content);
const timestamp = M_TIMESTAMP.findIn<number>(content);
const asset = M_ASSET.findIn<MAssetContent>(content);
// default asset type to self, as with location events
const assetType = asset?.type ?? LocationAssetType.Self;

This comment has been minimized.

Copy link
@t3chguy

t3chguy Aug 15, 2022

Member

This doesn't match the MSC

If m.asset is missing from the location's content the client should render it as m.self as that will be the most common use case. Otherwise, if it's not missing but the type is invalid or unknown the client should attempt to render it as a generic location.

This expression would do the wrong thing when asset is an empty object, where then type would be undefined and thus invalid/unknown


return {
description,
timeout,
live,
assetType: asset?.type,
assetType,
timestamp,
};
};
Expand Down

0 comments on commit c0d0ab6

Please sign in to comment.