Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -14,18 +14,18 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import classNames from 'classnames';
|
||||
import React, { useEffect } from 'react';
|
||||
import { Beacon, BeaconIdentifier } from 'matrix-js-sdk/src/matrix';
|
||||
import classNames from "classnames";
|
||||
import React, { useEffect } from "react";
|
||||
import { Beacon, BeaconIdentifier } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { useEventEmitterState } from '../../../hooks/useEventEmitter';
|
||||
import { _t } from '../../../languageHandler';
|
||||
import { OwnBeaconStore, OwnBeaconStoreEvent } from '../../../stores/OwnBeaconStore';
|
||||
import { Icon as LiveLocationIcon } from '../../../../res/img/location/live-location.svg';
|
||||
import { ViewRoomPayload } from '../../../dispatcher/payloads/ViewRoomPayload';
|
||||
import { Action } from '../../../dispatcher/actions';
|
||||
import dispatcher from '../../../dispatcher/dispatcher';
|
||||
import AccessibleButton from '../elements/AccessibleButton';
|
||||
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
|
||||
import { _t } from "../../../languageHandler";
|
||||
import { OwnBeaconStore, OwnBeaconStoreEvent } from "../../../stores/OwnBeaconStore";
|
||||
import { Icon as LiveLocationIcon } from "../../../../res/img/location/live-location.svg";
|
||||
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
|
||||
import { Action } from "../../../dispatcher/actions";
|
||||
import dispatcher from "../../../dispatcher/dispatcher";
|
||||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
|
||||
interface Props {
|
||||
isMinimized?: boolean;
|
||||
|
@ -52,12 +52,12 @@ const chooseBestBeacon = (
|
|||
|
||||
const getLabel = (hasStoppingErrors: boolean, hasLocationErrors: boolean): string => {
|
||||
if (hasStoppingErrors) {
|
||||
return _t('An error occurred while stopping your live location');
|
||||
return _t("An error occurred while stopping your live location");
|
||||
}
|
||||
if (hasLocationErrors) {
|
||||
return _t('An error occurred whilst sharing your live location');
|
||||
return _t("An error occurred whilst sharing your live location");
|
||||
}
|
||||
return _t('You are sharing your live location');
|
||||
return _t("You are sharing your live location");
|
||||
};
|
||||
|
||||
const useLivenessMonitor = (liveBeaconIds: BeaconIdentifier[], beacons: Map<BeaconIdentifier, Beacon>): void => {
|
||||
|
@ -66,8 +66,8 @@ const useLivenessMonitor = (liveBeaconIds: BeaconIdentifier[], beacons: Map<Beac
|
|||
// for inactive tabs
|
||||
// refresh beacon monitors when the tab becomes active again
|
||||
const onPageVisibilityChanged = () => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
liveBeaconIds.forEach(identifier => beacons.get(identifier)?.monitorLiveness());
|
||||
if (document.visibilityState === "visible") {
|
||||
liveBeaconIds.forEach((identifier) => beacons.get(identifier)?.monitorLiveness());
|
||||
}
|
||||
};
|
||||
if (liveBeaconIds.length) {
|
||||
|
@ -95,15 +95,14 @@ const LeftPanelLiveShareWarning: React.FC<Props> = ({ isMinimized }) => {
|
|||
const beaconIdsWithStoppingError = useEventEmitterState(
|
||||
OwnBeaconStore.instance,
|
||||
OwnBeaconStoreEvent.BeaconUpdateError,
|
||||
() => OwnBeaconStore.instance.getLiveBeaconIds().filter(
|
||||
beaconId => OwnBeaconStore.instance.beaconUpdateErrors.has(beaconId),
|
||||
),
|
||||
() =>
|
||||
OwnBeaconStore.instance
|
||||
.getLiveBeaconIds()
|
||||
.filter((beaconId) => OwnBeaconStore.instance.beaconUpdateErrors.has(beaconId)),
|
||||
);
|
||||
|
||||
const liveBeaconIds = useEventEmitterState(
|
||||
OwnBeaconStore.instance,
|
||||
OwnBeaconStoreEvent.LivenessChange,
|
||||
() => OwnBeaconStore.instance.getLiveBeaconIds(),
|
||||
const liveBeaconIds = useEventEmitterState(OwnBeaconStore.instance, OwnBeaconStoreEvent.LivenessChange, () =>
|
||||
OwnBeaconStore.instance.getLiveBeaconIds(),
|
||||
);
|
||||
|
||||
const hasLocationPublishErrors = !!beaconIdsWithLocationPublishError.length;
|
||||
|
@ -116,32 +115,38 @@ const LeftPanelLiveShareWarning: React.FC<Props> = ({ isMinimized }) => {
|
|||
}
|
||||
|
||||
const relevantBeacon = chooseBestBeacon(
|
||||
liveBeaconIds, beaconIdsWithStoppingError, beaconIdsWithLocationPublishError,
|
||||
liveBeaconIds,
|
||||
beaconIdsWithStoppingError,
|
||||
beaconIdsWithLocationPublishError,
|
||||
);
|
||||
|
||||
const onWarningClick = relevantBeacon ? () => {
|
||||
dispatcher.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: relevantBeacon.roomId,
|
||||
metricsTrigger: undefined,
|
||||
event_id: relevantBeacon.beaconInfoId,
|
||||
scroll_into_view: true,
|
||||
highlighted: true,
|
||||
});
|
||||
} : undefined;
|
||||
const onWarningClick = relevantBeacon
|
||||
? () => {
|
||||
dispatcher.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
room_id: relevantBeacon.roomId,
|
||||
metricsTrigger: undefined,
|
||||
event_id: relevantBeacon.beaconInfoId,
|
||||
scroll_into_view: true,
|
||||
highlighted: true,
|
||||
});
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const label = getLabel(hasStoppingErrors, hasLocationPublishErrors);
|
||||
|
||||
return <AccessibleButton
|
||||
className={classNames('mx_LeftPanelLiveShareWarning', {
|
||||
'mx_LeftPanelLiveShareWarning__minimized': isMinimized,
|
||||
'mx_LeftPanelLiveShareWarning__error': hasLocationPublishErrors || hasStoppingErrors,
|
||||
})}
|
||||
title={isMinimized ? label : undefined}
|
||||
onClick={onWarningClick}
|
||||
>
|
||||
{ isMinimized ? <LiveLocationIcon height={10} /> : label }
|
||||
</AccessibleButton>;
|
||||
return (
|
||||
<AccessibleButton
|
||||
className={classNames("mx_LeftPanelLiveShareWarning", {
|
||||
mx_LeftPanelLiveShareWarning__minimized: isMinimized,
|
||||
mx_LeftPanelLiveShareWarning__error: hasLocationPublishErrors || hasStoppingErrors,
|
||||
})}
|
||||
title={isMinimized ? label : undefined}
|
||||
onClick={onWarningClick}
|
||||
>
|
||||
{isMinimized ? <LiveLocationIcon height={10} /> : label}
|
||||
</AccessibleButton>
|
||||
);
|
||||
};
|
||||
|
||||
export default LeftPanelLiveShareWarning;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue