Message: Display notification on hidden sender click (#1302)

This commit is contained in:
Alexander Zinchuk 2021-07-21 17:44:50 +03:00
parent 89fc01c58e
commit 0b228be60d

View File

@ -157,7 +157,7 @@ type DispatchProps = Pick<GlobalActions, (
'openUserInfo' | 'openChat' | 'openUserInfo' | 'openChat' |
'cancelSendingMessage' | 'markMessagesRead' | 'cancelSendingMessage' | 'markMessagesRead' |
'sendPollVote' | 'toggleMessageSelection' | 'setReplyingToId' | 'openForwardMenu' | 'sendPollVote' | 'toggleMessageSelection' | 'setReplyingToId' | 'openForwardMenu' |
'clickInlineButton' | 'disableContextMenuHint' 'clickInlineButton' | 'disableContextMenuHint' | 'showNotification'
)>; )>;
const NBSP = '\u00A0'; const NBSP = '\u00A0';
@ -228,6 +228,7 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
openForwardMenu, openForwardMenu,
clickInlineButton, clickInlineButton,
disableContextMenuHint, disableContextMenuHint,
showNotification,
}) => { }) => {
// eslint-disable-next-line no-null/no-null // eslint-disable-next-line no-null/no-null
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
@ -235,6 +236,8 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
const bottomMarkerRef = useRef<HTMLDivElement>(null); const bottomMarkerRef = useRef<HTMLDivElement>(null);
// eslint-disable-next-line no-null/no-null // eslint-disable-next-line no-null/no-null
const appendixRef = useRef<HTMLDivElement>(null); const appendixRef = useRef<HTMLDivElement>(null);
const lang = useLang();
useOnIntersect(bottomMarkerRef, observeIntersectionForBottom); useOnIntersect(bottomMarkerRef, observeIntersectionForBottom);
@ -397,6 +400,9 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
const handleSenderClick = useCallback(() => { const handleSenderClick = useCallback(() => {
if (!senderPeer) { if (!senderPeer) {
if (asForwarded) {
showNotification({ message: lang('HidAccount') });
}
return; return;
} }
@ -405,7 +411,7 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
} else { } else {
openChat({ id: senderPeer.id }); openChat({ id: senderPeer.id });
} }
}, [senderPeer, openUserInfo, openChat]); }, [senderPeer, asForwarded, showNotification, lang, openUserInfo, openChat]);
const handleViaBotClick = useCallback(() => { const handleViaBotClick = useCallback(() => {
if (!botSender) { if (!botSender) {
@ -498,8 +504,6 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
}); });
}, [focusMessage, forwardInfo, message, chatId, isInDocumentGroup]); }, [focusMessage, forwardInfo, message, chatId, isInDocumentGroup]);
const lang = useLang();
let style = ''; let style = '';
let calculatedWidth; let calculatedWidth;
let noMediaCorners = false; let noMediaCorners = false;
@ -730,8 +734,8 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
<div className="message-title" dir="ltr"> <div className="message-title" dir="ltr">
{senderTitle ? ( {senderTitle ? (
<span <span
className={buildClassName(senderPeer && 'interactive', senderColor)} className={buildClassName('interactive', senderColor)}
onClick={senderPeer ? handleSenderClick : undefined} onClick={handleSenderClick}
dir="auto" dir="auto"
> >
{renderText(senderTitle)} {renderText(senderTitle)}
@ -986,5 +990,6 @@ export default memo(withGlobal<OwnProps>(
'openForwardMenu', 'openForwardMenu',
'clickInlineButton', 'clickInlineButton',
'disableContextMenuHint', 'disableContextMenuHint',
'showNotification',
]), ]),
)(Message)); )(Message));