[Refactoring] ApiMessage: Rename threadInfo → repliesThreadInfo
This commit is contained in:
parent
1fef97b82e
commit
5ac9eb9c16
@ -217,7 +217,7 @@ export function buildApiMessageWithChatId(
|
||||
...(keyboardButtons && { keyboardButtons, keyboardPlaceholder, isKeyboardSingleUse }),
|
||||
...(shouldHideKeyboardButtons && { shouldHideKeyboardButtons }),
|
||||
...(mtpMessage.viaBotId && { viaBotId: buildApiPeerId(mtpMessage.viaBotId, 'user') }),
|
||||
...(replies?.comments && { threadInfo: buildThreadInfo(replies, mtpMessage.id, chatId) }),
|
||||
...(replies?.comments && { repliesThreadInfo: buildThreadInfo(replies, mtpMessage.id, chatId) }),
|
||||
...(postAuthor && { postAuthorTitle: postAuthor }),
|
||||
isProtected,
|
||||
isForwardingAllowed,
|
||||
|
||||
@ -126,13 +126,13 @@ export async function fetchMessages({
|
||||
const messages = result.messages.map(buildApiMessage).filter(Boolean);
|
||||
const users = result.users.map(buildApiUser).filter(Boolean);
|
||||
const chats = result.chats.map((c) => buildApiChatFromPreview(c)).filter(Boolean);
|
||||
const threadInfos = messages.map(({ threadInfo }) => threadInfo).filter(Boolean);
|
||||
const repliesThreadInfos = messages.map(({ repliesThreadInfo }) => repliesThreadInfo).filter(Boolean);
|
||||
|
||||
return {
|
||||
messages,
|
||||
users,
|
||||
chats,
|
||||
threadInfos,
|
||||
repliesThreadInfos,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -409,7 +409,7 @@ export interface ApiMessage {
|
||||
keyboardPlaceholder?: string;
|
||||
isKeyboardSingleUse?: boolean;
|
||||
viaBotId?: string;
|
||||
threadInfo?: ApiThreadInfo;
|
||||
repliesThreadInfo?: ApiThreadInfo;
|
||||
postAuthorTitle?: string;
|
||||
isScheduled?: boolean;
|
||||
shouldHideKeyboardButtons?: boolean;
|
||||
|
||||
@ -216,7 +216,7 @@ type StateProps = {
|
||||
canAutoPlayMedia?: boolean;
|
||||
shouldLoopStickers?: boolean;
|
||||
autoLoadFileMaxSizeMb: number;
|
||||
threadInfo?: ApiThreadInfo;
|
||||
repliesThreadInfo?: ApiThreadInfo;
|
||||
reactionMessage?: ApiMessage;
|
||||
availableReactions?: ApiAvailableReaction[];
|
||||
defaultReaction?: ApiReaction;
|
||||
@ -318,7 +318,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
||||
canAutoPlayMedia,
|
||||
shouldLoopStickers,
|
||||
autoLoadFileMaxSizeMb,
|
||||
threadInfo,
|
||||
repliesThreadInfo,
|
||||
hasUnreadReaction,
|
||||
memoFirstUnreadIdRef,
|
||||
animationLevel,
|
||||
@ -379,7 +379,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
||||
const isOwn = isOwnMessage(message);
|
||||
const isScheduled = messageListType === 'scheduled' || message.isScheduled;
|
||||
const hasReply = isReplyMessage(message) && !shouldHideReply;
|
||||
const hasThread = Boolean(threadInfo) && messageListType === 'thread';
|
||||
const hasThread = Boolean(repliesThreadInfo) && messageListType === 'thread';
|
||||
const isCustomShape = getMessageCustomShape(message);
|
||||
const hasAnimatedEmoji = isCustomShape && (animatedEmoji || animatedCustomEmoji);
|
||||
const hasReactions = reactionMessage?.reactions && !areReactionsEmpty(reactionMessage.reactions);
|
||||
@ -531,7 +531,8 @@ const Message: FC<OwnProps & StateProps> = ({
|
||||
|
||||
const { phoneCall } = action || {};
|
||||
|
||||
const withCommentButton = threadInfo && !isInDocumentGroupNotLast && messageListType === 'thread' && !noComments;
|
||||
const withCommentButton = repliesThreadInfo && !isInDocumentGroupNotLast && messageListType === 'thread'
|
||||
&& !noComments;
|
||||
const withQuickReactionButton = !IS_TOUCH_ENV && !phoneCall && !isInSelectMode && defaultReaction
|
||||
&& !isInDocumentGroupNotLast;
|
||||
|
||||
@ -542,7 +543,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
||||
asForwarded,
|
||||
hasThread,
|
||||
forceSenderName,
|
||||
hasComments: threadInfo && threadInfo?.messagesCount > 0,
|
||||
hasComments: repliesThreadInfo && repliesThreadInfo.messagesCount > 0,
|
||||
hasActionButton: canForward || canFocus,
|
||||
hasReactions,
|
||||
isGeoLiveActive: location?.type === 'geoLive' && !isGeoLiveExpired(message, getServerTime(serverTimeOffset)),
|
||||
@ -1122,7 +1123,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
||||
<i className="icon-arrow-right" />
|
||||
</Button>
|
||||
) : undefined}
|
||||
{withCommentButton && <CommentButton threadInfo={threadInfo!} disabled={noComments} />}
|
||||
{withCommentButton && <CommentButton threadInfo={repliesThreadInfo!} disabled={noComments} />}
|
||||
{withAppendix && (
|
||||
<div className="svg-appendix" dangerouslySetInnerHTML={isOwn ? APPENDIX_OWN : APPENDIX_NOT_OWN} />
|
||||
)}
|
||||
@ -1179,7 +1180,8 @@ export default memo(withGlobal<OwnProps>(
|
||||
message, album, withSenderName, withAvatar, threadId, messageListType, isLastInDocumentGroup, isFirstInGroup,
|
||||
} = ownProps;
|
||||
const {
|
||||
id, chatId, viaBotId, replyToChatId, replyToMessageId, isOutgoing, threadInfo, forwardInfo, transcriptionId,
|
||||
id, chatId, viaBotId, replyToChatId, replyToMessageId, isOutgoing, repliesThreadInfo, forwardInfo,
|
||||
transcriptionId,
|
||||
} = message;
|
||||
|
||||
const chat = selectChat(global, chatId);
|
||||
@ -1237,8 +1239,8 @@ export default memo(withGlobal<OwnProps>(
|
||||
|
||||
const { canReply } = (messageListType === 'thread' && selectAllowedMessageActions(global, message, threadId)) || {};
|
||||
const isDownloading = selectIsDownloading(global, message);
|
||||
const actualThreadInfo = threadInfo
|
||||
? selectThreadInfo(global, threadInfo.chatId, threadInfo.threadId) || threadInfo
|
||||
const actualRepliesThreadInfo = repliesThreadInfo
|
||||
? selectThreadInfo(global, repliesThreadInfo.chatId, repliesThreadInfo.threadId) || repliesThreadInfo
|
||||
: undefined;
|
||||
|
||||
const isInDocumentGroup = Boolean(message.groupedId) && !message.isInAlbum;
|
||||
@ -1296,7 +1298,7 @@ export default memo(withGlobal<OwnProps>(
|
||||
canAutoPlayMedia: selectCanAutoPlayMedia(global, message),
|
||||
autoLoadFileMaxSizeMb: global.settings.byKey.autoLoadFileMaxSizeMb,
|
||||
shouldLoopStickers: selectShouldLoopStickers(global),
|
||||
threadInfo: actualThreadInfo,
|
||||
repliesThreadInfo: actualRepliesThreadInfo,
|
||||
availableReactions: global.availableReactions,
|
||||
defaultReaction: isMessageLocal(message) ? undefined : selectDefaultReaction(global, chatId),
|
||||
activeReactions: reactionMessage && global.activeReactions[reactionMessage.id],
|
||||
|
||||
@ -113,10 +113,10 @@ addActionHandler('openChat', (global, actions, payload) => {
|
||||
}
|
||||
|
||||
// Please telegram send us some updates about linked chat 🙏
|
||||
if (chat?.lastMessage?.threadInfo) {
|
||||
if (chat?.lastMessage?.repliesThreadInfo) {
|
||||
actions.requestThreadInfoUpdate({
|
||||
chatId: chat.lastMessage.threadInfo.chatId,
|
||||
threadId: chat.lastMessage.threadInfo.threadId,
|
||||
chatId: chat.lastMessage.repliesThreadInfo.chatId,
|
||||
threadId: chat.lastMessage.repliesThreadInfo.threadId,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -851,7 +851,7 @@ async function loadViewportMessages(
|
||||
}
|
||||
|
||||
const {
|
||||
messages, users, chats, threadInfos,
|
||||
messages, users, chats, repliesThreadInfos,
|
||||
} = result;
|
||||
|
||||
let global = getGlobal();
|
||||
@ -870,7 +870,7 @@ async function loadViewportMessages(
|
||||
|
||||
global = addUsers(global, buildCollectionByKey(users, 'id'));
|
||||
global = addChats(global, buildCollectionByKey(chats, 'id'));
|
||||
global = updateThreadInfos(global, chatId, threadInfos);
|
||||
global = updateThreadInfos(global, chatId, repliesThreadInfos);
|
||||
|
||||
let listedIds = selectListedIds(global, chatId, threadId);
|
||||
const outlyingIds = selectOutlyingIds(global, chatId, threadId);
|
||||
|
||||
@ -139,7 +139,7 @@ async function loadAndReplaceMessages() {
|
||||
global = safeReplaceViewportIds(global, activeCurrentChatId, activeThreadId, listedIds);
|
||||
global = updateChats(global, buildCollectionByKey(result.chats, 'id'));
|
||||
global = updateUsers(global, buildCollectionByKey(result.users, 'id'));
|
||||
global = updateThreadInfos(global, activeCurrentChatId, result.threadInfos);
|
||||
global = updateThreadInfos(global, activeCurrentChatId, result.repliesThreadInfos);
|
||||
|
||||
areMessagesLoaded = true;
|
||||
}
|
||||
|
||||
@ -67,12 +67,12 @@ addActionHandler('apiUpdate', (global, actions, update) => {
|
||||
global = updateWithLocalMedia(global, chatId, id, message);
|
||||
global = updateListedAndViewportIds(global, actions, message as ApiMessage);
|
||||
|
||||
if (message.threadInfo) {
|
||||
if (message.repliesThreadInfo) {
|
||||
global = updateThreadInfo(
|
||||
global,
|
||||
message.threadInfo.chatId,
|
||||
message.threadInfo.threadId,
|
||||
message.threadInfo,
|
||||
message.repliesThreadInfo.chatId,
|
||||
message.repliesThreadInfo.threadId,
|
||||
message.repliesThreadInfo,
|
||||
);
|
||||
}
|
||||
|
||||
@ -185,12 +185,12 @@ addActionHandler('apiUpdate', (global, actions, update) => {
|
||||
global = updateWithLocalMedia(global, chatId, id, message);
|
||||
|
||||
const newMessage = selectChatMessage(global, chatId, id)!;
|
||||
if (message.threadInfo) {
|
||||
if (message.repliesThreadInfo) {
|
||||
global = updateThreadInfo(
|
||||
global,
|
||||
message.threadInfo.chatId,
|
||||
message.threadInfo.threadId,
|
||||
message.threadInfo,
|
||||
message.repliesThreadInfo.chatId,
|
||||
message.repliesThreadInfo.threadId,
|
||||
message.repliesThreadInfo,
|
||||
);
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ addActionHandler('apiUpdate', (global, actions, update) => {
|
||||
&& chat.lastMessage?.id === message.id
|
||||
&& selectIsChatWithBot(global, chat)
|
||||
&& selectIsMessageInCurrentMessageList(global, chatId, message as ApiMessage)
|
||||
&& selectIsViewportNewest(global, chatId, message.threadInfo?.threadId || MAIN_THREAD_ID)
|
||||
&& selectIsViewportNewest(global, chatId, message.repliesThreadInfo?.threadId || MAIN_THREAD_ID)
|
||||
) {
|
||||
actions.focusLastMessage();
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ export function deleteChatMessages(
|
||||
global = updateCurrentMessageList(global, chatId);
|
||||
}
|
||||
if (originalPost) {
|
||||
global = updateChatMessage(global, fromChatId!, fromMessageId!, { threadInfo: undefined });
|
||||
global = updateChatMessage(global, fromChatId!, fromMessageId!, { repliesThreadInfo: undefined });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user