mirror of https://github.com/vector-im/riot-web
hide live location option when composer has relation (#8746)
Signed-off-by: Kerry Archibald <kerrya@element.io>pull/28788/head^2
parent
228abb6f07
commit
91cbd4dc8a
|
@ -38,8 +38,16 @@ type Props = Omit<ILocationPickerProps, 'onChoose' | 'shareType'> & {
|
||||||
relation?: IEventRelation;
|
relation?: IEventRelation;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getEnabledShareTypes = (): LocationShareType[] => {
|
const getEnabledShareTypes = (relation): LocationShareType[] => {
|
||||||
const enabledShareTypes = [LocationShareType.Own, LocationShareType.Live];
|
const enabledShareTypes = [
|
||||||
|
LocationShareType.Own,
|
||||||
|
];
|
||||||
|
|
||||||
|
// live locations cannot have a relation
|
||||||
|
// hide the option when composer has a relation
|
||||||
|
if (!relation) {
|
||||||
|
enabledShareTypes.push(LocationShareType.Live);
|
||||||
|
}
|
||||||
|
|
||||||
if (SettingsStore.getValue("feature_location_share_pin_drop")) {
|
if (SettingsStore.getValue("feature_location_share_pin_drop")) {
|
||||||
enabledShareTypes.push(LocationShareType.Pin);
|
enabledShareTypes.push(LocationShareType.Pin);
|
||||||
|
@ -57,7 +65,7 @@ const LocationShareMenu: React.FC<Props> = ({
|
||||||
relation,
|
relation,
|
||||||
}) => {
|
}) => {
|
||||||
const matrixClient = useContext(MatrixClientContext);
|
const matrixClient = useContext(MatrixClientContext);
|
||||||
const enabledShareTypes = getEnabledShareTypes();
|
const enabledShareTypes = getEnabledShareTypes(relation);
|
||||||
const isLiveShareEnabled = useFeatureEnabled("feature_location_share_live");
|
const isLiveShareEnabled = useFeatureEnabled("feature_location_share_live");
|
||||||
|
|
||||||
const multipleShareTypesEnabled = enabledShareTypes.length > 1;
|
const multipleShareTypesEnabled = enabledShareTypes.length > 1;
|
||||||
|
|
|
@ -16,12 +16,13 @@ limitations under the License.
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount, ReactWrapper } from 'enzyme';
|
import { mount, ReactWrapper } from 'enzyme';
|
||||||
|
import { mocked } from 'jest-mock';
|
||||||
import { RoomMember } from 'matrix-js-sdk/src/models/room-member';
|
import { RoomMember } from 'matrix-js-sdk/src/models/room-member';
|
||||||
import { MatrixClient } from 'matrix-js-sdk/src/client';
|
import { MatrixClient } from 'matrix-js-sdk/src/client';
|
||||||
import { mocked } from 'jest-mock';
|
import { RelationType } from 'matrix-js-sdk/src/matrix';
|
||||||
import { act } from 'react-dom/test-utils';
|
|
||||||
import { M_ASSET, LocationAssetType } from 'matrix-js-sdk/src/@types/location';
|
|
||||||
import { logger } from 'matrix-js-sdk/src/logger';
|
import { logger } from 'matrix-js-sdk/src/logger';
|
||||||
|
import { M_ASSET, LocationAssetType } from 'matrix-js-sdk/src/@types/location';
|
||||||
|
import { act } from 'react-dom/test-utils';
|
||||||
|
|
||||||
import LocationShareMenu from '../../../../src/components/views/location/LocationShareMenu';
|
import LocationShareMenu from '../../../../src/components/views/location/LocationShareMenu';
|
||||||
import MatrixClientContext from '../../../../src/contexts/MatrixClientContext';
|
import MatrixClientContext from '../../../../src/contexts/MatrixClientContext';
|
||||||
|
@ -375,6 +376,16 @@ describe('<LocationShareMenu />', () => {
|
||||||
describe('Live location share', () => {
|
describe('Live location share', () => {
|
||||||
beforeEach(() => enableSettings(["feature_location_share_live"]));
|
beforeEach(() => enableSettings(["feature_location_share_live"]));
|
||||||
|
|
||||||
|
it('does not display live location share option when composer has a relation', () => {
|
||||||
|
const relation = {
|
||||||
|
rel_type: RelationType.Thread,
|
||||||
|
event_id: '12345',
|
||||||
|
};
|
||||||
|
const component = getComponent({ relation });
|
||||||
|
|
||||||
|
expect(getShareTypeOption(component, LocationShareType.Live).length).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
it('creates beacon info event on submission', () => {
|
it('creates beacon info event on submission', () => {
|
||||||
const onFinished = jest.fn();
|
const onFinished = jest.fn();
|
||||||
const component = getComponent({ onFinished });
|
const component = getComponent({ onFinished });
|
||||||
|
|
Loading…
Reference in New Issue