Live location share - forward latest location (PSF-1044) (#8860)

* handle beacon location events in ForwardDialog

* add transformer for forwarded events in MessageContextMenu

* remove canForward

* update snapshots for beacon model change

* add comments

* fix bad copy pasted test

* add test for beacon locations
This commit is contained in:
Kerry 2022-06-17 15:27:08 +02:00 committed by GitHub
parent 0a90674e89
commit b51ef246ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 292 additions and 81 deletions

View file

@ -30,7 +30,7 @@ import Modal from '../../../Modal';
import Resend from '../../../Resend';
import SettingsStore from '../../../settings/SettingsStore';
import { isUrlPermitted } from '../../../HtmlUtils';
import { canEditContent, canForward, editEvent, isContentActionable, isLocationEvent } from '../../../utils/EventUtils';
import { canEditContent, editEvent, isContentActionable, isLocationEvent } from '../../../utils/EventUtils';
import IconizedContextMenu, { IconizedContextMenuOption, IconizedContextMenuOptionList } from './IconizedContextMenu';
import { ReadPinsEventId } from "../right_panel/types";
import { Action } from "../../../dispatcher/actions";
@ -51,6 +51,7 @@ import { GetRelationsForEvent, IEventTileOps } from "../rooms/EventTile";
import { OpenForwardDialogPayload } from "../../../dispatcher/payloads/OpenForwardDialogPayload";
import { OpenReportEventDialogPayload } from "../../../dispatcher/payloads/OpenReportEventDialogPayload";
import { createMapSiteLinkFromEvent } from '../../../utils/location';
import { getForwardableEvent } from '../../../events/forward/getForwardableEvent';
interface IProps extends IPosition {
chevronFace: ChevronFace;
@ -188,10 +189,10 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
this.closeMenu();
};
private onForwardClick = (): void => {
private onForwardClick = (forwardableEvent: MatrixEvent) => (): void => {
dis.dispatch<OpenForwardDialogPayload>({
action: Action.OpenForwardDialog,
event: this.props.mxEvent,
event: forwardableEvent,
permalinkCreator: this.props.permalinkCreator,
});
this.closeMenu();
@ -379,12 +380,13 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
}
let forwardButton: JSX.Element;
if (contentActionable && canForward(mxEvent)) {
const forwardableEvent = getForwardableEvent(mxEvent, cli);
if (contentActionable && forwardableEvent) {
forwardButton = (
<IconizedContextMenuOption
iconClassName="mx_MessageContextMenu_iconForward"
label={_t("Forward")}
onClick={this.onForwardClick}
onClick={this.onForwardClick(forwardableEvent)}
/>
);
}