Action Message: Fix missing origin name
This commit is contained in:
parent
97891c02a5
commit
74d1c8547a
@ -8,7 +8,6 @@ import {
|
|||||||
getChatTitle,
|
getChatTitle,
|
||||||
getMessageContent, getMessageSummaryText,
|
getMessageContent, getMessageSummaryText,
|
||||||
getUserFullName,
|
getUserFullName,
|
||||||
isUserId,
|
|
||||||
} from '../../../modules/helpers';
|
} from '../../../modules/helpers';
|
||||||
import trimText from '../../../util/trimText';
|
import trimText from '../../../util/trimText';
|
||||||
import { formatCurrency } from '../../../util/formatCurrency';
|
import { formatCurrency } from '../../../util/formatCurrency';
|
||||||
@ -31,7 +30,8 @@ const NBSP = '\u00A0';
|
|||||||
export function renderActionMessageText(
|
export function renderActionMessageText(
|
||||||
lang: LangFn,
|
lang: LangFn,
|
||||||
message: ApiMessage,
|
message: ApiMessage,
|
||||||
actionOrigin?: ApiUser | ApiChat,
|
actionOriginUser?: ApiUser,
|
||||||
|
actionOriginChat?: ApiChat,
|
||||||
targetUsers?: ApiUser[],
|
targetUsers?: ApiUser[],
|
||||||
targetMessage?: ApiMessage,
|
targetMessage?: ApiMessage,
|
||||||
targetChatId?: string,
|
targetChatId?: string,
|
||||||
@ -65,9 +65,12 @@ export function renderActionMessageText(
|
|||||||
processed = processPlaceholder(
|
processed = processPlaceholder(
|
||||||
unprocessed,
|
unprocessed,
|
||||||
'%action_origin%',
|
'%action_origin%',
|
||||||
actionOrigin
|
actionOriginUser ? (
|
||||||
? (!options.isEmbedded && renderOriginContent(lang, actionOrigin, options.asPlain)) || NBSP
|
(!options.isEmbedded && renderUserContent(actionOriginUser, options.asPlain)) || NBSP
|
||||||
: 'User',
|
|
||||||
|
) : actionOriginChat ? (
|
||||||
|
(!options.isEmbedded && renderChatContent(lang, actionOriginChat, options.asPlain)) || NBSP
|
||||||
|
) : 'User',
|
||||||
);
|
);
|
||||||
|
|
||||||
unprocessed = processed.pop() as string;
|
unprocessed = processed.pop() as string;
|
||||||
@ -174,12 +177,6 @@ function renderMessageContent(lang: LangFn, message: ApiMessage, options: Action
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderOriginContent(lang: LangFn, origin: ApiUser | ApiChat, asPlain?: boolean) {
|
|
||||||
return isUserId(origin.id)
|
|
||||||
? renderUserContent(origin as ApiUser, asPlain)
|
|
||||||
: renderChatContent(lang, origin as ApiChat, asPlain);
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderGroupCallContent(groupCall: Partial<ApiGroupCall>, text: TextPart[]): string | TextPart | undefined {
|
function renderGroupCallContent(groupCall: Partial<ApiGroupCall>, text: TextPart[]): string | TextPart | undefined {
|
||||||
return (
|
return (
|
||||||
<GroupCallLink groupCall={groupCall}>
|
<GroupCallLink groupCall={groupCall}>
|
||||||
|
|||||||
@ -235,16 +235,15 @@ const Chat: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAction) {
|
if (isAction) {
|
||||||
const actionOrigin = chat && (isChatChannel(chat) || lastMessage.senderId === lastMessage.chatId)
|
const isChat = chat && (isChatChannel(chat) || lastMessage.senderId === lastMessage.chatId);
|
||||||
? chat
|
|
||||||
: lastMessageSender;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<p className="last-message" dir={lang.isRtl ? 'auto' : 'ltr'}>
|
<p className="last-message" dir={lang.isRtl ? 'auto' : 'ltr'}>
|
||||||
{renderActionMessageText(
|
{renderActionMessageText(
|
||||||
lang,
|
lang,
|
||||||
lastMessage,
|
lastMessage,
|
||||||
actionOrigin,
|
!isChat ? lastMessageSender : undefined,
|
||||||
|
isChat ? chat : undefined,
|
||||||
actionTargetUsers,
|
actionTargetUsers,
|
||||||
actionTargetMessage,
|
actionTargetMessage,
|
||||||
actionTargetChatId,
|
actionTargetChatId,
|
||||||
|
|||||||
@ -36,7 +36,8 @@ type OwnProps = {
|
|||||||
|
|
||||||
type StateProps = {
|
type StateProps = {
|
||||||
usersById: Record<string, ApiUser>;
|
usersById: Record<string, ApiUser>;
|
||||||
sender?: ApiUser | ApiChat;
|
senderUser?: ApiUser;
|
||||||
|
senderChat?: ApiChat;
|
||||||
targetUserIds?: string[];
|
targetUserIds?: string[];
|
||||||
targetMessage?: ApiMessage;
|
targetMessage?: ApiMessage;
|
||||||
targetChatId?: string;
|
targetChatId?: string;
|
||||||
@ -54,7 +55,8 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
|
|||||||
appearanceOrder = 0,
|
appearanceOrder = 0,
|
||||||
isLastInList,
|
isLastInList,
|
||||||
usersById,
|
usersById,
|
||||||
sender,
|
senderUser,
|
||||||
|
senderChat,
|
||||||
targetUserIds,
|
targetUserIds,
|
||||||
targetMessage,
|
targetMessage,
|
||||||
targetChatId,
|
targetChatId,
|
||||||
@ -91,7 +93,8 @@ const ActionMessage: FC<OwnProps & StateProps> = ({
|
|||||||
const content = renderActionMessageText(
|
const content = renderActionMessageText(
|
||||||
lang,
|
lang,
|
||||||
message,
|
message,
|
||||||
sender,
|
senderUser,
|
||||||
|
senderChat,
|
||||||
targetUsers,
|
targetUsers,
|
||||||
targetMessage,
|
targetMessage,
|
||||||
targetChatId,
|
targetChatId,
|
||||||
@ -159,13 +162,14 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const { direction: focusDirection, noHighlight: noFocusHighlight } = (isFocused && global.focusedMessage) || {};
|
const { direction: focusDirection, noHighlight: noFocusHighlight } = (isFocused && global.focusedMessage) || {};
|
||||||
|
|
||||||
const chat = selectChat(global, message.chatId);
|
const chat = selectChat(global, message.chatId);
|
||||||
const sender = chat && (isChatChannel(chat) || userId === message.chatId)
|
const isChat = chat && (isChatChannel(chat) || userId === message.chatId);
|
||||||
? chat
|
const senderUser = !isChat && userId ? selectUser(global, userId) : undefined;
|
||||||
: userId ? selectUser(global, userId) : undefined;
|
const senderChat = isChat ? chat : undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
usersById,
|
usersById,
|
||||||
sender,
|
senderUser,
|
||||||
|
senderChat,
|
||||||
targetChatId,
|
targetChatId,
|
||||||
targetUserIds,
|
targetUserIds,
|
||||||
targetMessage,
|
targetMessage,
|
||||||
|
|||||||
@ -277,13 +277,13 @@ function getNotificationContent(chat: ApiChat, message: ApiMessage) {
|
|||||||
let body: string;
|
let body: string;
|
||||||
if (selectShouldShowMessagePreview(chat, selectNotifySettings(global), selectNotifyExceptions(global))) {
|
if (selectShouldShowMessagePreview(chat, selectNotifySettings(global), selectNotifyExceptions(global))) {
|
||||||
if (isActionMessage(message)) {
|
if (isActionMessage(message)) {
|
||||||
const actionOrigin = chat && (isChatChannel(chat) || message.senderId === message.chatId)
|
const isChat = chat && (isChatChannel(chat) || message.senderId === message.chatId);
|
||||||
? chat
|
|
||||||
: messageSender;
|
|
||||||
body = renderActionMessageText(
|
body = renderActionMessageText(
|
||||||
getTranslation,
|
getTranslation,
|
||||||
message,
|
message,
|
||||||
actionOrigin,
|
!isChat ? messageSender : undefined,
|
||||||
|
isChat ? chat : undefined,
|
||||||
actionTargetUsers,
|
actionTargetUsers,
|
||||||
actionTargetMessage,
|
actionTargetMessage,
|
||||||
actionTargetChatId,
|
actionTargetChatId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user