Forums: Fix displaying as muted (#3808)

This commit is contained in:
Alexander Zinchuk 2023-09-08 18:39:12 +02:00
parent b421ac25d2
commit c5c6207772
2 changed files with 10 additions and 2 deletions

View File

@ -48,7 +48,7 @@ const ChatBadge: FC<OwnProps> = ({
const shouldBeMuted = useMemo(() => {
const hasUnmutedUnreadTopics = chat.topics
&& Object.values(chat.topics).some((acc) => acc.isMuted && acc.unreadCount);
&& Object.values(chat.topics).some((acc) => !acc.isMuted && acc.unreadCount);
return isMuted || (chat.topics && !hasUnmutedUnreadTopics);
}, [chat, isMuted]);

View File

@ -1,6 +1,6 @@
import { addActionHandler, getGlobal, setGlobal } from '../../index';
import type { ApiUpdateChat } from '../../../api/types';
import type { ApiMessage, ApiUpdateChat } from '../../../api/types';
import type { ActionReturnType } from '../../types';
import { MAIN_THREAD_ID } from '../../../api/types';
@ -25,6 +25,7 @@ import {
selectThreadParam,
selectChatFullInfo,
selectTabState,
selectTopicFromMessage,
} from '../../selectors';
import { updateUnreadReactions } from '../../reducers/reactions';
import { updateTabState } from '../../reducers/tabs';
@ -143,6 +144,13 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
});
}
const topic = chat.isForum ? selectTopicFromMessage(global, message as ApiMessage) : undefined;
if (topic) {
global = updateTopic(global, update.chatId, topic.id, {
unreadCount: topic.unreadCount ? topic.unreadCount + 1 : 1,
});
}
setGlobal(global);
notifyAboutMessage({