Message Meta: Show info about imported message (#2167)
This commit is contained in:
parent
28d87bd580
commit
5db1f528bf
@ -392,6 +392,7 @@ function buildApiMessageForwardInfo(fwdFrom: GramJs.MessageFwdHeader, isChatWith
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
date: fwdFrom.date,
|
date: fwdFrom.date,
|
||||||
|
isImported: fwdFrom.imported,
|
||||||
isChannelPost: Boolean(fwdFrom.channelPost),
|
isChannelPost: Boolean(fwdFrom.channelPost),
|
||||||
channelPostId: fwdFrom.channelPost,
|
channelPostId: fwdFrom.channelPost,
|
||||||
isLinkedChannelPost: Boolean(fwdFrom.channelPost && savedFromPeerId && !isChatWithSelf),
|
isLinkedChannelPost: Boolean(fwdFrom.channelPost && savedFromPeerId && !isChatWithSelf),
|
||||||
|
|||||||
@ -286,6 +286,7 @@ export interface ApiWebPage {
|
|||||||
|
|
||||||
export interface ApiMessageForwardInfo {
|
export interface ApiMessageForwardInfo {
|
||||||
date: number;
|
date: number;
|
||||||
|
isImported?: boolean;
|
||||||
isChannelPost: boolean;
|
isChannelPost: boolean;
|
||||||
channelPostId?: number;
|
channelPostId?: number;
|
||||||
isLinkedChannelPost?: boolean;
|
isLinkedChannelPost?: boolean;
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.message-time,
|
.message-time,
|
||||||
|
.message-imported,
|
||||||
.message-signature,
|
.message-signature,
|
||||||
.message-views {
|
.message-views {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
@ -40,6 +41,7 @@
|
|||||||
margin-inline-start: 0.1875rem;
|
margin-inline-start: 0.1875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-imported,
|
||||||
.message-signature {
|
.message-signature {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import type { FC } from '../../../lib/teact/teact';
|
import type { FC } from '../../../lib/teact/teact';
|
||||||
import React, { memo, useMemo } from '../../../lib/teact/teact';
|
import React, { memo, useMemo } from '../../../lib/teact/teact';
|
||||||
|
import { getActions } from '../../../global';
|
||||||
|
|
||||||
import type { ApiAvailableReaction, ApiMessage, ApiMessageOutgoingStatus } from '../../../api/types';
|
import type { ApiAvailableReaction, ApiMessage, ApiMessageOutgoingStatus } from '../../../api/types';
|
||||||
import type { ActiveReaction } from '../../../global/types';
|
import type { ActiveReaction } from '../../../global/types';
|
||||||
@ -34,10 +35,18 @@ const MessageMeta: FC<OwnProps> = ({
|
|||||||
activeReaction, withReactionOffset, availableReactions,
|
activeReaction, withReactionOffset, availableReactions,
|
||||||
reactionMessage,
|
reactionMessage,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { showNotification } = getActions();
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
const [isActivated, markActivated] = useFlag();
|
const [isActivated, markActivated] = useFlag();
|
||||||
|
|
||||||
const reactions = withReactions && reactionMessage?.reactions?.results.filter((l) => l.count > 0);
|
const reactions = withReactions && reactionMessage?.reactions?.results.filter((l) => l.count > 0);
|
||||||
|
const handleClick = (e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
showNotification({
|
||||||
|
message: lang('ImportedInfo'),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const title = useMemo(() => {
|
const title = useMemo(() => {
|
||||||
if (!isActivated) return undefined;
|
if (!isActivated) return undefined;
|
||||||
@ -58,9 +67,15 @@ const MessageMeta: FC<OwnProps> = ({
|
|||||||
return text;
|
return text;
|
||||||
}, [isActivated, lang, message]);
|
}, [isActivated, lang, message]);
|
||||||
|
|
||||||
|
const fullClassName = buildClassName(
|
||||||
|
'MessageMeta',
|
||||||
|
withReactionOffset && 'reactions-offset',
|
||||||
|
message.forwardInfo?.isImported && 'is-imported',
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={buildClassName('MessageMeta', withReactionOffset && 'reactions-offset')}
|
className={fullClassName}
|
||||||
dir={lang.isRtl ? 'rtl' : 'ltr'}
|
dir={lang.isRtl ? 'rtl' : 'ltr'}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
data-ignore-on-paste
|
data-ignore-on-paste
|
||||||
@ -85,6 +100,14 @@ const MessageMeta: FC<OwnProps> = ({
|
|||||||
<span className="message-signature">{renderText(signature)}</span>
|
<span className="message-signature">{renderText(signature)}</span>
|
||||||
)}
|
)}
|
||||||
<span className="message-time" title={title} onMouseEnter={markActivated}>
|
<span className="message-time" title={title} onMouseEnter={markActivated}>
|
||||||
|
{message.forwardInfo?.isImported && (
|
||||||
|
<>
|
||||||
|
<span className="message-imported" onClick={handleClick}>
|
||||||
|
{formatDateTimeToString(message.forwardInfo.date * 1000, lang.code, true)}
|
||||||
|
</span>
|
||||||
|
<span className="message-imported" onClick={handleClick}>{lang('ImportedMessage')}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{message.isEdited && `${lang('EditedMessage')} `}
|
{message.isEdited && `${lang('EditedMessage')} `}
|
||||||
{formatTime(lang, message.date * 1000)}
|
{formatTime(lang, message.date * 1000)}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@ -171,7 +171,7 @@
|
|||||||
bottom: -0.5rem !important;
|
bottom: -0.5rem !important;
|
||||||
margin-top: -0.25rem;
|
margin-top: -0.25rem;
|
||||||
|
|
||||||
&:not([dir="rtl"]) {
|
&:not([dir="rtl"]):not(.is-imported) {
|
||||||
margin-top: -1.25rem;
|
margin-top: -1.25rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -290,7 +290,7 @@ export function formatDateToString(
|
|||||||
return formatDayToStringWithCache(dayStartAt, locale, noYear, monthFormat, noDay);
|
return formatDayToStringWithCache(dayStartAt, locale, noYear, monthFormat, noDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatDateTimeToString(datetime: Date | number, locale = 'en-US') {
|
export function formatDateTimeToString(datetime: Date | number, locale = 'en-US', noSeconds?: boolean) {
|
||||||
const date = typeof datetime === 'number' ? new Date(datetime) : datetime;
|
const date = typeof datetime === 'number' ? new Date(datetime) : datetime;
|
||||||
return date.toLocaleString(
|
return date.toLocaleString(
|
||||||
locale,
|
locale,
|
||||||
@ -300,7 +300,7 @@ export function formatDateTimeToString(datetime: Date | number, locale = 'en-US'
|
|||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
hour: 'numeric',
|
hour: 'numeric',
|
||||||
minute: 'numeric',
|
minute: 'numeric',
|
||||||
second: 'numeric',
|
second: noSeconds ? undefined : 'numeric',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user