mirror of https://github.com/vector-im/riot-web
Remove the Forward and Share buttons for location messages only (#7423)
parent
d6af7294e4
commit
de881d2321
|
@ -15,11 +15,12 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React, { ReactElement } from 'react';
|
||||||
import { EventStatus, MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
import { EventStatus, MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
||||||
import { EventType, RelationType } from "matrix-js-sdk/src/@types/event";
|
import { EventType, RelationType } from "matrix-js-sdk/src/@types/event";
|
||||||
import { Relations } from 'matrix-js-sdk/src/models/relations';
|
import { Relations } from 'matrix-js-sdk/src/models/relations';
|
||||||
import { POLL_START_EVENT_TYPE } from "matrix-js-sdk/src/@types/polls";
|
import { POLL_START_EVENT_TYPE } from "matrix-js-sdk/src/@types/polls";
|
||||||
|
import { LOCATION_EVENT_TYPE } from 'matrix-js-sdk/src/@types/location';
|
||||||
|
|
||||||
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
||||||
import dis from '../../../dispatcher/dispatcher';
|
import dis from '../../../dispatcher/dispatcher';
|
||||||
|
@ -313,13 +314,15 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isContentActionable(mxEvent)) {
|
if (isContentActionable(mxEvent)) {
|
||||||
forwardButton = (
|
if (canForward(mxEvent)) {
|
||||||
<IconizedContextMenuOption
|
forwardButton = (
|
||||||
iconClassName="mx_MessageContextMenu_iconForward"
|
<IconizedContextMenuOption
|
||||||
label={_t("Forward")}
|
iconClassName="mx_MessageContextMenu_iconForward"
|
||||||
onClick={this.onForwardClick}
|
label={_t("Forward")}
|
||||||
/>
|
onClick={this.onForwardClick}
|
||||||
);
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.state.canPin) {
|
if (this.state.canPin) {
|
||||||
pinButton = (
|
pinButton = (
|
||||||
|
@ -352,26 +355,29 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let permalink;
|
let permalink: string | null = null;
|
||||||
if (this.props.permalinkCreator) {
|
let permalinkButton: ReactElement | null = null;
|
||||||
permalink = this.props.permalinkCreator.forEvent(this.props.mxEvent.getId());
|
if (canShare(mxEvent)) {
|
||||||
}
|
if (this.props.permalinkCreator) {
|
||||||
const permalinkButton = (
|
permalink = this.props.permalinkCreator.forEvent(this.props.mxEvent.getId());
|
||||||
<IconizedContextMenuOption
|
}
|
||||||
iconClassName="mx_MessageContextMenu_iconPermalink"
|
permalinkButton = (
|
||||||
onClick={this.onPermalinkClick}
|
<IconizedContextMenuOption
|
||||||
label={_t('Share')}
|
iconClassName="mx_MessageContextMenu_iconPermalink"
|
||||||
element="a"
|
onClick={this.onPermalinkClick}
|
||||||
{
|
label={_t('Share')}
|
||||||
// XXX: Typescript signature for AccessibleButton doesn't work properly for non-inputs like `a`
|
element="a"
|
||||||
...{
|
{
|
||||||
href: permalink,
|
// XXX: Typescript signature for AccessibleButton doesn't work properly for non-inputs like `a`
|
||||||
target: "_blank",
|
...{
|
||||||
rel: "noreferrer noopener",
|
href: permalink,
|
||||||
|
target: "_blank",
|
||||||
|
rel: "noreferrer noopener",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
/>
|
||||||
/>
|
);
|
||||||
);
|
}
|
||||||
|
|
||||||
if (this.canEndPoll(mxEvent)) {
|
if (this.canEndPoll(mxEvent)) {
|
||||||
endPollButton = (
|
endPollButton = (
|
||||||
|
@ -486,3 +492,22 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function canForward(event: MatrixEvent): boolean {
|
||||||
|
return !isLocationEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
function canShare(event: MatrixEvent): boolean {
|
||||||
|
return !isLocationEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLocationEvent(event: MatrixEvent): boolean {
|
||||||
|
const eventType = event.getType();
|
||||||
|
return (
|
||||||
|
LOCATION_EVENT_TYPE.matches(eventType) ||
|
||||||
|
(
|
||||||
|
eventType === EventType.RoomMessage &&
|
||||||
|
LOCATION_EVENT_TYPE.matches(event.getContent().msgtype)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue