Live location share - link to timeline tile from share warning (PSF-1078) (#8752)

* navigate to live location tile from left panel live warning

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

* navigate to beacon tile from room live share warning

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

* add cursor

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry 2022-06-07 12:15:09 +02:00 committed by GitHub
parent f65e8d088e
commit 56b0b79fb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 11 deletions

View file

@ -16,7 +16,7 @@ limitations under the License.
import classNames from 'classnames';
import React, { useEffect } from 'react';
import { Beacon, BeaconIdentifier, Room } from 'matrix-js-sdk/src/matrix';
import { Beacon, BeaconIdentifier } from 'matrix-js-sdk/src/matrix';
import { useEventEmitterState } from '../../../hooks/useEventEmitter';
import { _t } from '../../../languageHandler';
@ -33,13 +33,12 @@ interface Props {
/**
* Choose the most relevant beacon
* and get its roomId
*/
const chooseBestBeaconRoomId = (
const chooseBestBeacon = (
liveBeaconIds: BeaconIdentifier[],
updateErrorBeaconIds: BeaconIdentifier[],
locationErrorBeaconIds: BeaconIdentifier[],
): Room['roomId'] | undefined => {
): Beacon | undefined => {
// both lists are ordered by creation timestamp in store
// so select latest beacon
const beaconId = updateErrorBeaconIds?.[0] ?? locationErrorBeaconIds?.[0] ?? liveBeaconIds?.[0];
@ -48,7 +47,7 @@ const chooseBestBeaconRoomId = (
}
const beacon = OwnBeaconStore.instance.getBeaconById(beaconId);
return beacon?.roomId;
return beacon;
};
const getLabel = (hasStoppingErrors: boolean, hasLocationErrors: boolean): string => {
@ -116,15 +115,18 @@ const LeftPanelLiveShareWarning: React.FC<Props> = ({ isMinimized }) => {
return null;
}
const relevantBeaconRoomId = chooseBestBeaconRoomId(
const relevantBeacon = chooseBestBeacon(
liveBeaconIds, beaconIdsWithStoppingError, beaconIdsWithLocationPublishError,
);
const onWarningClick = relevantBeaconRoomId ? () => {
const onWarningClick = relevantBeacon ? () => {
dispatcher.dispatch<ViewRoomPayload>({
action: Action.ViewRoom,
room_id: relevantBeaconRoomId,
room_id: relevantBeacon.roomId,
metricsTrigger: undefined,
event_id: relevantBeacon.beaconInfoId,
scroll_into_view: true,
highlighted: true,
});
} : undefined;