Messages: Fix message sending in threads (#6008)

This commit is contained in:
Alexander Zinchuk 2025-06-18 17:41:01 +02:00
parent 2da7c72c44
commit c50bc7347a
2 changed files with 11 additions and 1 deletions

View File

@ -138,6 +138,7 @@ import {
selectSendAs,
selectTabState,
selectThreadIdFromMessage,
selectThreadInfo,
selectTopic,
selectTranslationLanguage,
selectUser,
@ -344,7 +345,11 @@ addActionHandler('sendMessage', async (global, actions, payload): Promise<void>
const messageReplyInfo = selectMessageReplyInfo(global, chatId!, threadId!, draftReplyInfo);
const replyInfo = storyReplyInfo || messageReplyInfo;
const lastMessageId = selectChatLastMessageId(global, chatId!);
const threadInfo = selectThreadInfo(global, chatId!, threadId!);
const lastMessageId = threadId === MAIN_THREAD_ID
? selectChatLastMessageId(global, chatId!) : threadInfo?.lastMessageId;
const messagePriceInStars = await getPeerStarsForMessage(global, chatId!);
const params: SendMessageParams = {

View File

@ -1088,6 +1088,11 @@ function updateChatLastMessage<T extends GlobalState>(
});
}
const threadId = selectThreadIdFromMessage(global, message);
global = updateThreadInfo(global, chatId, threadId, {
lastMessageId: message.id,
});
const savedDialogId = selectSavedDialogIdFromMessage(global, message);
if (savedDialogId) {
global = updateChatLastMessageId(global, savedDialogId, message.id, 'saved');