hide live location option when composer has relation (#8746)

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry 2022-06-03 10:28:19 +02:00 committed by GitHub
parent 228abb6f07
commit 91cbd4dc8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 6 deletions

View file

@ -38,8 +38,16 @@ type Props = Omit<ILocationPickerProps, 'onChoose' | 'shareType'> & {
relation?: IEventRelation;
};
const getEnabledShareTypes = (): LocationShareType[] => {
const enabledShareTypes = [LocationShareType.Own, LocationShareType.Live];
const getEnabledShareTypes = (relation): LocationShareType[] => {
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")) {
enabledShareTypes.push(LocationShareType.Pin);
@ -57,7 +65,7 @@ const LocationShareMenu: React.FC<Props> = ({
relation,
}) => {
const matrixClient = useContext(MatrixClientContext);
const enabledShareTypes = getEnabledShareTypes();
const enabledShareTypes = getEnabledShareTypes(relation);
const isLiveShareEnabled = useFeatureEnabled("feature_location_share_live");
const multipleShareTypesEnabled = enabledShareTypes.length > 1;