Location sharing > back button (#7958)

* add back/cancel buttons to share dialog

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

* test buttons

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

* improve weird indentation

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

* relint

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

* PR tweaks

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

* quotes

Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
Kerry 2022-03-03 11:30:46 +01:00 committed by GitHub
parent 7aefa34420
commit ebc2267e52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 211 additions and 56 deletions

View file

@ -24,6 +24,7 @@ import LocationPicker, { ILocationPickerProps } from "./LocationPicker";
import { shareLocation } from './shareLocation';
import SettingsStore from '../../../settings/SettingsStore';
import ShareType, { LocationShareType } from './ShareType';
import ShareDialogButtons from './ShareDialogButtons';
type Props = Omit<ILocationPickerProps, 'onChoose'> & {
onFinished: (ev?: SyntheticEvent) => void;
@ -55,8 +56,10 @@ const LocationShareMenu: React.FC<Props> = ({
const matrixClient = useContext(MatrixClientContext);
const enabledShareTypes = getEnabledShareTypes();
const [shareType, setShareType] = useState<LocationShareType>(
enabledShareTypes.length === 1 ? LocationShareType.Own : undefined,
const multipleShareTypesEnabled = enabledShareTypes.length > 1;
const [shareType, setShareType] = useState<LocationShareType | undefined>(
multipleShareTypesEnabled ? undefined : LocationShareType.Own,
);
return <ContextMenu
@ -72,6 +75,7 @@ const LocationShareMenu: React.FC<Props> = ({
/>
:
<ShareType setShareType={setShareType} enabledShareTypes={enabledShareTypes} /> }
<ShareDialogButtons displayBack={!!shareType && multipleShareTypesEnabled} onBack={() => setShareType(undefined)} onCancel={onFinished} />
</div>
</ContextMenu>;
};