Chat: Open forum panel on click (#2272)

This commit is contained in:
Alexander Zinchuk 2023-01-10 18:35:57 +01:00
parent 3643a3fe6d
commit e2f111fa72
2 changed files with 10 additions and 10 deletions

View File

@ -126,6 +126,7 @@ const Chat: FC<OwnProps & StateProps> = ({
openChat, openChat,
focusLastMessage, focusLastMessage,
loadTopics, loadTopics,
openForumPanel,
} = getActions(); } = getActions();
const [isDeleteModalOpen, openDeleteModal, closeDeleteModal] = useFlag(); const [isDeleteModalOpen, openDeleteModal, closeDeleteModal] = useFlag();
@ -155,12 +156,17 @@ const Chat: FC<OwnProps & StateProps> = ({
}); });
const handleClick = useCallback(() => { const handleClick = useCallback(() => {
if (isForum) {
openForumPanel({ chatId });
return;
}
openChat({ id: chatId, shouldReplaceHistory: true }, { forceOnHeavyAnimation: true }); openChat({ id: chatId, shouldReplaceHistory: true }, { forceOnHeavyAnimation: true });
if (isSelected && canScrollDown) { if (isSelected && canScrollDown) {
focusLastMessage(); focusLastMessage();
} }
}, [openChat, chatId, isSelected, canScrollDown, focusLastMessage]); }, [isForum, openChat, chatId, isSelected, canScrollDown, openForumPanel, focusLastMessage]);
const handleDragEnter = useCallback((e) => { const handleDragEnter = useCallback((e) => {
e.preventDefault(); e.preventDefault();

View File

@ -5,13 +5,13 @@ import { MAIN_THREAD_ID } from '../../../api/types';
import { import {
exitMessageSelectMode, replaceThreadParam, updateCurrentMessageList, exitMessageSelectMode, replaceThreadParam, updateCurrentMessageList,
} from '../../reducers'; } from '../../reducers';
import { selectChat, selectCurrentMessageList } from '../../selectors'; import { selectCurrentMessageList } from '../../selectors';
import { closeLocalTextSearch } from './localSearch'; import { closeLocalTextSearch } from './localSearch';
addActionHandler('openChat', (global, actions, payload) => { addActionHandler('openChat', (global, actions, payload) => {
const { const {
id, id,
threadId, threadId = MAIN_THREAD_ID,
type = 'thread', type = 'thread',
shouldReplaceHistory = false, shouldReplaceHistory = false,
} = payload; } = payload;
@ -35,7 +35,7 @@ addActionHandler('openChat', (global, actions, payload) => {
|| currentMessageList.type !== type || currentMessageList.type !== type
)) { )) {
if (id) { if (id) {
global = replaceThreadParam(global, id, threadId || MAIN_THREAD_ID, 'replyStack', []); global = replaceThreadParam(global, id, threadId, 'replyStack', []);
} }
global = exitMessageSelectMode(global); global = exitMessageSelectMode(global);
@ -58,12 +58,6 @@ addActionHandler('openChat', (global, actions, payload) => {
actions.closeForumPanel(); 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); return updateCurrentMessageList(global, id, threadId, type, shouldReplaceHistory);
}); });