Chat: Fix read chat action (#5774)

Co-authored-by: zubiden <19638254+zubiden@users.noreply.github.com>
This commit is contained in:
Alexander Zinchuk 2025-03-27 19:03:24 +01:00
parent 9bbad7c202
commit aef7c39809
4 changed files with 22 additions and 3 deletions

View File

@ -14,6 +14,10 @@
&.closing {
transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}
body.is-macos & {
height: 1.375rem;
}
}
.ChatBadge-wrapper {

View File

@ -1178,7 +1178,7 @@ addActionHandler('markChatUnread', (global, actions, payload): ActionReturnType
});
});
addActionHandler('markChatRead', async (global, actions, payload): Promise<void> => {
addActionHandler('markChatMessagesRead', async (global, actions, payload): Promise<void> => {
const { id } = payload;
const chat = selectChat(global, id);
if (!chat) return;
@ -1186,6 +1186,9 @@ addActionHandler('markChatRead', async (global, actions, payload): Promise<void>
await callApi('markMessageListRead', { chat, threadId: MAIN_THREAD_ID });
actions.readAllMentions({ chatId: id });
actions.readAllReactions({ chatId: id });
if (chat.hasUnreadMark) {
actions.markChatRead({ id });
}
return;
}
@ -1213,6 +1216,17 @@ addActionHandler('markChatRead', async (global, actions, payload): Promise<void>
}
});
addActionHandler('markChatRead', (global, actions, payload): ActionReturnType => {
const { id } = payload;
const chat = selectChat(global, id);
if (!chat) return;
callApi('toggleDialogUnread', {
chat,
hasUnreadMark: !chat.hasUnreadMark,
});
});
addActionHandler('markTopicRead', (global, actions, payload): ActionReturnType => {
const { chatId, topicId } = payload;
const chat = selectChat(global, chatId);

View File

@ -368,6 +368,7 @@ export interface ActionPayloads {
};
markChatUnread: { id: string };
markChatRead: { id: string };
markChatMessagesRead: { id: string };
loadChatFolders: undefined;
loadRecommendedChatFolders: undefined;
editChatFolder: {

View File

@ -79,7 +79,7 @@ const useChatContextActions = ({
toggleSavedDialogPinned,
updateChatMutedState,
toggleChatArchived,
markChatRead,
markChatMessagesRead,
markChatUnread,
openChatInNewTab,
} = getActions();
@ -150,7 +150,7 @@ const useChatContextActions = ({
}
const actionMaskAsRead = (chat.unreadCount || chat.hasUnreadMark)
? { title: lang('MarkAsRead'), icon: 'readchats', handler: () => markChatRead({ id: chat.id }) }
? { title: lang('MarkAsRead'), icon: 'readchats', handler: () => markChatMessagesRead({ id: chat.id }) }
: undefined;
const actionMarkAsUnread = !(chat.unreadCount || chat.hasUnreadMark) && !chat.isForum
? { title: lang('MarkAsUnread'), icon: 'unread', handler: () => markChatUnread({ id: chat.id }) }