Message List: Focus bot message when updated inline keyboard

This commit is contained in:
Alexander Zinchuk 2021-08-27 21:05:52 +03:00
parent 0625edb308
commit 53ec3098b8

View File

@ -37,6 +37,7 @@ import {
selectViewportIds,
selectFirstUnreadId,
selectChat,
selectIsChatWithBot,
} from '../../selectors';
import { getMessageContent, isChatPrivate, isMessageLocal } from '../../helpers';
@ -136,6 +137,20 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
setGlobal(global);
// Scroll down if bot message height is changed with an updated inline keyboard.
// A drawback: this will scroll down even if the previous scroll was not at bottom.
const chat = selectChat(global, chatId);
if (
chat
&& !message.isOutgoing
&& chat.lastMessage?.id === message.id
&& selectIsChatWithBot(global, chat)
&& isMessageInCurrentMessageList(global, chatId, message as ApiMessage)
&& selectIsViewportNewest(global, chatId, message.threadInfo?.threadId || MAIN_THREAD_ID)
) {
actions.focusLastMessage();
}
break;
}