Apply prettier formatting

This commit is contained in:
Michael Weimann 2022-12-12 12:24:14 +01:00
parent 1cac306093
commit 526645c791
No known key found for this signature in database
GPG key ID: 53F535A266BB9584
1576 changed files with 65385 additions and 62478 deletions

View file

@ -14,35 +14,35 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React from 'react';
import { Room } from 'matrix-js-sdk/src/matrix';
import React from "react";
import { Room } from "matrix-js-sdk/src/matrix";
import { _t } from '../../../languageHandler';
import { useEventEmitterState } from '../../../hooks/useEventEmitter';
import { OwnBeaconStore, OwnBeaconStoreEvent } from '../../../stores/OwnBeaconStore';
import { useOwnLiveBeacons } from '../../../utils/beacon';
import AccessibleButton, { ButtonEvent } from '../elements/AccessibleButton';
import Spinner from '../elements/Spinner';
import StyledLiveBeaconIcon from './StyledLiveBeaconIcon';
import { Icon as CloseIcon } from '../../../../res/img/image-view/close.svg';
import LiveTimeRemaining from './LiveTimeRemaining';
import dispatcher from '../../../dispatcher/dispatcher';
import { ViewRoomPayload } from '../../../dispatcher/payloads/ViewRoomPayload';
import { Action } from '../../../dispatcher/actions';
import { _t } from "../../../languageHandler";
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
import { OwnBeaconStore, OwnBeaconStoreEvent } from "../../../stores/OwnBeaconStore";
import { useOwnLiveBeacons } from "../../../utils/beacon";
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
import Spinner from "../elements/Spinner";
import StyledLiveBeaconIcon from "./StyledLiveBeaconIcon";
import { Icon as CloseIcon } from "../../../../res/img/image-view/close.svg";
import LiveTimeRemaining from "./LiveTimeRemaining";
import dispatcher from "../../../dispatcher/dispatcher";
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
import { Action } from "../../../dispatcher/actions";
const getLabel = (hasLocationPublishError: boolean, hasStopSharingError: boolean): string => {
if (hasLocationPublishError) {
return _t('An error occurred whilst sharing your live location, please try again');
return _t("An error occurred whilst sharing your live location, please try again");
}
if (hasStopSharingError) {
return _t('An error occurred while stopping your live location, please try again');
return _t("An error occurred while stopping your live location, please try again");
}
return _t('You are sharing your live location');
return _t("You are sharing your live location");
};
interface RoomLiveShareWarningInnerProps {
liveBeaconIds: string[];
roomId: Room['roomId'];
roomId: Room["roomId"];
}
const RoomLiveShareWarningInner: React.FC<RoomLiveShareWarningInnerProps> = ({ liveBeaconIds, roomId }) => {
const {
@ -86,45 +86,48 @@ const RoomLiveShareWarningInner: React.FC<RoomLiveShareWarningInnerProps> = ({ l
});
};
return <div
className='mx_RoomLiveShareWarning'
onClick={onClick}
>
<StyledLiveBeaconIcon className="mx_RoomLiveShareWarning_icon" withError={hasError} />
return (
<div className="mx_RoomLiveShareWarning" onClick={onClick}>
<StyledLiveBeaconIcon className="mx_RoomLiveShareWarning_icon" withError={hasError} />
<span className="mx_RoomLiveShareWarning_label">
{ getLabel(hasLocationPublishError, hasStopSharingError) }
</span>
<span className="mx_RoomLiveShareWarning_label">
{getLabel(hasLocationPublishError, hasStopSharingError)}
</span>
{ stoppingInProgress &&
<span className='mx_RoomLiveShareWarning_spinner'><Spinner h={16} w={16} /></span>
}
{ !stoppingInProgress && !hasError && <LiveTimeRemaining beacon={beacon} /> }
{stoppingInProgress && (
<span className="mx_RoomLiveShareWarning_spinner">
<Spinner h={16} w={16} />
</span>
)}
{!stoppingInProgress && !hasError && <LiveTimeRemaining beacon={beacon} />}
<AccessibleButton
className='mx_RoomLiveShareWarning_stopButton'
data-test-id='room-live-share-primary-button'
onClick={stopPropagationWrapper(onButtonClick)}
kind='danger'
element='button'
disabled={stoppingInProgress}
>
{ hasError ? _t('Retry') : _t('Stop') }
</AccessibleButton>
{ hasLocationPublishError && <AccessibleButton
data-test-id='room-live-share-wire-error-close-button'
title={_t('Stop and close')}
element='button'
className='mx_RoomLiveShareWarning_closeButton'
onClick={stopPropagationWrapper(onStopSharing)}
>
<CloseIcon className='mx_RoomLiveShareWarning_closeButtonIcon' />
</AccessibleButton> }
</div>;
<AccessibleButton
className="mx_RoomLiveShareWarning_stopButton"
data-test-id="room-live-share-primary-button"
onClick={stopPropagationWrapper(onButtonClick)}
kind="danger"
element="button"
disabled={stoppingInProgress}
>
{hasError ? _t("Retry") : _t("Stop")}
</AccessibleButton>
{hasLocationPublishError && (
<AccessibleButton
data-test-id="room-live-share-wire-error-close-button"
title={_t("Stop and close")}
element="button"
className="mx_RoomLiveShareWarning_closeButton"
onClick={stopPropagationWrapper(onStopSharing)}
>
<CloseIcon className="mx_RoomLiveShareWarning_closeButtonIcon" />
</AccessibleButton>
)}
</div>
);
};
interface Props {
roomId: Room['roomId'];
roomId: Room["roomId"];
}
const RoomLiveShareWarning: React.FC<Props> = ({ roomId }) => {
// do we have an active geolocation.watchPosition
@ -134,10 +137,8 @@ const RoomLiveShareWarning: React.FC<Props> = ({ roomId }) => {
() => OwnBeaconStore.instance.isMonitoringLiveLocation,
);
const liveBeaconIds = useEventEmitterState(
OwnBeaconStore.instance,
OwnBeaconStoreEvent.LivenessChange,
() => OwnBeaconStore.instance.getLiveBeaconIds(roomId),
const liveBeaconIds = useEventEmitterState(OwnBeaconStore.instance, OwnBeaconStoreEvent.LivenessChange, () =>
OwnBeaconStore.instance.getLiveBeaconIds(roomId),
);
if (!isMonitoringLiveLocation || !liveBeaconIds.length) {