Adds all message actions to context menu
This commit is contained in:
parent
b71122c7f9
commit
4c85c04d45
2 changed files with 18 additions and 7 deletions
|
@ -18,7 +18,10 @@ import type {
|
||||||
import { ReadStatus } from '../../messages/MessageReadStatus';
|
import { ReadStatus } from '../../messages/MessageReadStatus';
|
||||||
import { Avatar } from '../Avatar';
|
import { Avatar } from '../Avatar';
|
||||||
import { Spinner } from '../Spinner';
|
import { Spinner } from '../Spinner';
|
||||||
import { MessageBodyReadMore } from './MessageBodyReadMore';
|
import {
|
||||||
|
doesMessageBodyOverflow,
|
||||||
|
MessageBodyReadMore,
|
||||||
|
} from './MessageBodyReadMore';
|
||||||
import { MessageMetadata } from './MessageMetadata';
|
import { MessageMetadata } from './MessageMetadata';
|
||||||
import { ImageGrid } from './ImageGrid';
|
import { ImageGrid } from './ImageGrid';
|
||||||
import { GIF } from './GIF';
|
import { GIF } from './GIF';
|
||||||
|
@ -1367,7 +1370,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
{({ ref: popperRef }) => {
|
{({ ref: popperRef }) => {
|
||||||
// Only attach the popper reference to the reaction button if it is
|
// Only attach the popper reference to the reaction button if it is
|
||||||
// visible (it is hidden when the timeline is narrow)
|
// visible (it is hidden when the timeline is narrow)
|
||||||
const maybePopperRef = this.shouldShowAdditionalMenuButtons()
|
const maybePopperRef = this.isWindowWidthNotNarrow()
|
||||||
? popperRef
|
? popperRef
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
@ -1421,7 +1424,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
{({ ref: popperRef }) => {
|
{({ ref: popperRef }) => {
|
||||||
// Only attach the popper reference to the collapsed menu button if the reaction
|
// Only attach the popper reference to the collapsed menu button if the reaction
|
||||||
// button is not visible (it is hidden when the timeline is narrow)
|
// button is not visible (it is hidden when the timeline is narrow)
|
||||||
const maybePopperRef = !this.shouldShowAdditionalMenuButtons()
|
const maybePopperRef = !this.isWindowWidthNotNarrow()
|
||||||
? popperRef
|
? popperRef
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
@ -1459,7 +1462,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
`module-message__buttons--${direction}`
|
`module-message__buttons--${direction}`
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{this.shouldShowAdditionalMenuButtons() && (
|
{this.isWindowWidthNotNarrow() && (
|
||||||
<>
|
<>
|
||||||
{canReply ? reactButton : null}
|
{canReply ? reactButton : null}
|
||||||
{canDownload ? downloadButton : null}
|
{canDownload ? downloadButton : null}
|
||||||
|
@ -1520,6 +1523,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
showForwardMessageModal,
|
showForwardMessageModal,
|
||||||
showMessageDetail,
|
showMessageDetail,
|
||||||
status,
|
status,
|
||||||
|
text,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const canForward = !isTapToView && !deletedForEveryone;
|
const canForward = !isTapToView && !deletedForEveryone;
|
||||||
|
@ -1531,10 +1535,13 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
direction === 'outgoing';
|
direction === 'outgoing';
|
||||||
const multipleAttachments = attachments && attachments.length > 1;
|
const multipleAttachments = attachments && attachments.length > 1;
|
||||||
|
|
||||||
|
const shouldShowAdditional =
|
||||||
|
doesMessageBodyOverflow(text || '') || !this.isWindowWidthNotNarrow();
|
||||||
|
|
||||||
const menu = (
|
const menu = (
|
||||||
<ContextMenu id={triggerId}>
|
<ContextMenu id={triggerId}>
|
||||||
{canDownload &&
|
{canDownload &&
|
||||||
!this.shouldShowAdditionalMenuButtons() &&
|
shouldShowAdditional &&
|
||||||
!isSticker &&
|
!isSticker &&
|
||||||
!multipleAttachments &&
|
!multipleAttachments &&
|
||||||
!isTapToView &&
|
!isTapToView &&
|
||||||
|
@ -1550,7 +1557,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
{i18n('downloadAttachment')}
|
{i18n('downloadAttachment')}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
) : null}
|
) : null}
|
||||||
{canReply && !this.shouldShowAdditionalMenuButtons() ? (
|
{canReply && shouldShowAdditional ? (
|
||||||
<>
|
<>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
attributes={{
|
attributes={{
|
||||||
|
@ -1664,7 +1671,7 @@ export class Message extends React.PureComponent<Props, State> {
|
||||||
return ReactDOM.createPortal(menu, document.body);
|
return ReactDOM.createPortal(menu, document.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private shouldShowAdditionalMenuButtons(): boolean {
|
private isWindowWidthNotNarrow(): boolean {
|
||||||
const { containerWidthBreakpoint } = this.props;
|
const { containerWidthBreakpoint } = this.props;
|
||||||
return containerWidthBreakpoint !== WidthBreakpoint.Narrow;
|
return containerWidthBreakpoint !== WidthBreakpoint.Narrow;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,10 @@ const INITIAL_LENGTH = 800;
|
||||||
const INCREMENT_COUNT = 3000;
|
const INCREMENT_COUNT = 3000;
|
||||||
const BUFFER = 100;
|
const BUFFER = 100;
|
||||||
|
|
||||||
|
export function doesMessageBodyOverflow(str: string): boolean {
|
||||||
|
return str.length > INITIAL_LENGTH + BUFFER;
|
||||||
|
}
|
||||||
|
|
||||||
function graphemeAwareSlice(
|
function graphemeAwareSlice(
|
||||||
str: string,
|
str: string,
|
||||||
length: number
|
length: number
|
||||||
|
|
Loading…
Add table
Reference in a new issue