diff --git a/src/components/left/main/Chat.tsx b/src/components/left/main/Chat.tsx index 961743f1d..e3eb8233d 100644 --- a/src/components/left/main/Chat.tsx +++ b/src/components/left/main/Chat.tsx @@ -126,6 +126,7 @@ const Chat: FC = ({ openChat, focusLastMessage, loadTopics, + openForumPanel, } = getActions(); const [isDeleteModalOpen, openDeleteModal, closeDeleteModal] = useFlag(); @@ -155,12 +156,17 @@ const Chat: FC = ({ }); const handleClick = useCallback(() => { + if (isForum) { + openForumPanel({ chatId }); + return; + } + openChat({ id: chatId, shouldReplaceHistory: true }, { forceOnHeavyAnimation: true }); if (isSelected && canScrollDown) { focusLastMessage(); } - }, [openChat, chatId, isSelected, canScrollDown, focusLastMessage]); + }, [isForum, openChat, chatId, isSelected, canScrollDown, openForumPanel, focusLastMessage]); const handleDragEnter = useCallback((e) => { e.preventDefault(); diff --git a/src/global/actions/ui/chats.ts b/src/global/actions/ui/chats.ts index 630e8e527..2982f0eac 100644 --- a/src/global/actions/ui/chats.ts +++ b/src/global/actions/ui/chats.ts @@ -5,13 +5,13 @@ import { MAIN_THREAD_ID } from '../../../api/types'; import { exitMessageSelectMode, replaceThreadParam, updateCurrentMessageList, } from '../../reducers'; -import { selectChat, selectCurrentMessageList } from '../../selectors'; +import { selectCurrentMessageList } from '../../selectors'; import { closeLocalTextSearch } from './localSearch'; addActionHandler('openChat', (global, actions, payload) => { const { id, - threadId, + threadId = MAIN_THREAD_ID, type = 'thread', shouldReplaceHistory = false, } = payload; @@ -35,7 +35,7 @@ addActionHandler('openChat', (global, actions, payload) => { || currentMessageList.type !== type )) { if (id) { - global = replaceThreadParam(global, id, threadId || MAIN_THREAD_ID, 'replyStack', []); + global = replaceThreadParam(global, id, threadId, 'replyStack', []); } global = exitMessageSelectMode(global); @@ -58,12 +58,6 @@ addActionHandler('openChat', (global, actions, payload) => { actions.closeForumPanel(); } - if (id && !threadId) { - const chat = selectChat(global, id); - // Prevent chat opening on forum click - if (chat?.isForum) return global; - } - return updateCurrentMessageList(global, id, threadId, type, shouldReplaceHistory); });