Pinned Messages: Fixing the reaction setting on the last message (#3139)

This commit is contained in:
Alexander Zinchuk 2023-05-03 20:20:51 +04:00
parent ca5ee6f21c
commit a5a3a86953

View File

@ -42,6 +42,7 @@ import {
selectChatScheduledMessages, selectChatScheduledMessages,
selectTabState, selectTabState,
selectRequestedTranslationLanguage, selectRequestedTranslationLanguage,
selectPinnedIds,
} from '../../selectors'; } from '../../selectors';
import { compact, findLast } from '../../../util/iteratees'; import { compact, findLast } from '../../../util/iteratees';
import { getServerTime } from '../../../util/serverTime'; import { getServerTime } from '../../../util/serverTime';
@ -322,13 +323,22 @@ addActionHandler('focusLastMessage', (global, actions, payload): ActionReturnTyp
return; return;
} }
const { chatId, threadId } = currentMessageList; const { chatId, threadId, type } = currentMessageList;
let lastMessageId: number | undefined; let lastMessageId: number | undefined;
if (threadId === MAIN_THREAD_ID) { if (threadId === MAIN_THREAD_ID) {
const chat = selectChat(global, chatId); if (type === 'pinned') {
const pinnedMessageIds = selectPinnedIds(global, chatId, MAIN_THREAD_ID);
if (!pinnedMessageIds?.length) {
return;
}
lastMessageId = chat?.lastMessage?.id; lastMessageId = pinnedMessageIds[pinnedMessageIds.length - 1];
} else {
const chat = selectChat(global, chatId);
lastMessageId = chat?.lastMessage?.id;
}
} else { } else {
const threadInfo = selectThreadInfo(global, chatId, threadId); const threadInfo = selectThreadInfo(global, chatId, threadId);
@ -342,6 +352,7 @@ addActionHandler('focusLastMessage', (global, actions, payload): ActionReturnTyp
actions.focusMessage({ actions.focusMessage({
chatId, chatId,
threadId, threadId,
messageListType: type,
messageId: lastMessageId, messageId: lastMessageId,
noHighlight: true, noHighlight: true,
noForumTopicPanel: true, noForumTopicPanel: true,
@ -433,6 +444,7 @@ addActionHandler('focusMessage', (global, actions, payload): ActionReturnType =>
actions.openChat({ actions.openChat({
id: chatId, id: chatId,
threadId, threadId,
type: messageListType,
shouldReplaceHistory, shouldReplaceHistory,
noForumTopicPanel, noForumTopicPanel,
tabId, tabId,
@ -454,6 +466,7 @@ addActionHandler('focusMessage', (global, actions, payload): ActionReturnType =>
actions.openChat({ actions.openChat({
id: chatId, id: chatId,
threadId, threadId,
type: messageListType,
shouldReplaceHistory, shouldReplaceHistory,
noForumTopicPanel, noForumTopicPanel,
tabId, tabId,