apply strictnullchecks to src/components/views/beacon/* (#10272)

This commit is contained in:
Kerry 2023-03-02 22:58:05 +13:00 committed by GitHub
parent ffa047be68
commit de6a1a661c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 48 additions and 30 deletions

View file

@ -42,14 +42,14 @@ const BeaconListItem: React.FC<Props & HTMLProps<HTMLLIElement>> = ({ beacon, ..
const matrixClient = useContext(MatrixClientContext);
const room = matrixClient.getRoom(beacon.roomId);
if (!latestLocationState || !beacon.isLive) {
if (!latestLocationState || !beacon.isLive || !room) {
return null;
}
const isSelfLocation = beacon.beaconInfo.assetType === LocationAssetType.Self;
const beaconMember = isSelfLocation ? room.getMember(beacon.beaconInfoOwner) : undefined;
const isSelfLocation = beacon.beaconInfo?.assetType === LocationAssetType.Self;
const beaconMember = isSelfLocation ? room.getMember(beacon.beaconInfoOwner) : null;
const humanizedUpdateTime = humanizeTime(latestLocationState.timestamp);
const humanizedUpdateTime = (latestLocationState.timestamp && humanizeTime(latestLocationState.timestamp)) || "";
return (
<li className="mx_BeaconListItem" {...rest}>
@ -62,7 +62,7 @@ const BeaconListItem: React.FC<Props & HTMLProps<HTMLLIElement>> = ({ beacon, ..
<BeaconStatus
className="mx_BeaconListItem_status"
beacon={beacon}
label={beaconMember?.name || beacon.beaconInfo.description || beacon.beaconInfoOwner}
label={beaconMember?.name || beacon.beaconInfo?.description || beacon.beaconInfoOwner}
displayStatus={BeaconDisplayStatus.Active}
>
{/* eat events from interactive share buttons