Live location sharing: create beacon info event from location picker (#8072)
* create beacon info event with defaulted duration Signed-off-by: Kerry Archibald <kerrya@element.io> * add shareLiveLocation fn Signed-off-by: Kerry Archibald <kerrya@element.io> * test share live location Signed-off-by: Kerry Archibald <kerrya@element.io> * i18n Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
4e4ce65f58
commit
cdcf6d0fd1
5 changed files with 152 additions and 36 deletions
|
@ -21,11 +21,12 @@ import { IEventRelation } from 'matrix-js-sdk/src/models/event';
|
|||
import MatrixClientContext from '../../../contexts/MatrixClientContext';
|
||||
import ContextMenu, { AboveLeftOf } from '../../structures/ContextMenu';
|
||||
import LocationPicker, { ILocationPickerProps } from "./LocationPicker";
|
||||
import { shareLocation } from './shareLocation';
|
||||
import { shareLiveLocation, shareLocation } from './shareLocation';
|
||||
import SettingsStore from '../../../settings/SettingsStore';
|
||||
import ShareDialogButtons from './ShareDialogButtons';
|
||||
import ShareType from './ShareType';
|
||||
import { LocationShareType } from './shareLocation';
|
||||
import { OwnProfileStore } from '../../../stores/OwnProfileStore';
|
||||
|
||||
type Props = Omit<ILocationPickerProps, 'onChoose' | 'shareType'> & {
|
||||
onFinished: (ev?: SyntheticEvent) => void;
|
||||
|
@ -66,20 +67,27 @@ const LocationShareMenu: React.FC<Props> = ({
|
|||
multipleShareTypesEnabled ? undefined : LocationShareType.Own,
|
||||
);
|
||||
|
||||
const displayName = OwnProfileStore.instance.displayName;
|
||||
|
||||
const onLocationSubmit = shareType === LocationShareType.Live ?
|
||||
shareLiveLocation(matrixClient, roomId, displayName, openMenu) :
|
||||
shareLocation(matrixClient, roomId, shareType, relation, openMenu);
|
||||
|
||||
return <ContextMenu
|
||||
{...menuPosition}
|
||||
onFinished={onFinished}
|
||||
managed={false}
|
||||
>
|
||||
<div className="mx_LocationShareMenu">
|
||||
{ shareType ? <LocationPicker
|
||||
sender={sender}
|
||||
shareType={shareType}
|
||||
onChoose={shareLocation(matrixClient, roomId, shareType, relation, openMenu)}
|
||||
onFinished={onFinished}
|
||||
/>
|
||||
:
|
||||
<ShareType setShareType={setShareType} enabledShareTypes={enabledShareTypes} /> }
|
||||
{ shareType ?
|
||||
<LocationPicker
|
||||
sender={sender}
|
||||
shareType={shareType}
|
||||
onChoose={onLocationSubmit}
|
||||
onFinished={onFinished}
|
||||
/> :
|
||||
<ShareType setShareType={setShareType} enabledShareTypes={enabledShareTypes} />
|
||||
}
|
||||
<ShareDialogButtons displayBack={!!shareType && multipleShareTypesEnabled} onBack={() => setShareType(undefined)} onCancel={onFinished} />
|
||||
</div>
|
||||
</ContextMenu>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue