diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 6d376e1c4..10a6e6936 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -3794,14 +3794,14 @@ void InnerWidget::setupShortcuts() { }); request->check(Command::ReadChat) && request->handle([=] { - const auto history = _selected ? _selected->history() : nullptr; - if (history) { - if (history->chatListBadgesState().unread) { - session().data().histories().readInbox(history); - } - return true; + const auto thread = _selected ? _selected->thread() : nullptr; + if (!thread) { + return false; } - return (history != nullptr); + if (Window::IsUnreadThread(thread)) { + Window::MarkAsReadThread(thread); + } + return true; }); request->check(Command::ShowContacts) && request->handle([=] { diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 3ab37825b..c92268082 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -161,31 +161,6 @@ void SetActionText(not_null action, rpl::producer &&text) { }, *lifetime); } -[[nodiscard]] bool IsUnreadThread(not_null thread) { - return thread->chatListBadgesState().unread; -} - -void MarkAsReadThread(not_null thread) { - const auto readHistory = [&](not_null history) { - history->owner().histories().readInbox(history); - }; - if (!IsUnreadThread(thread)) { - return; - } else if (const auto forum = thread->asForum()) { - forum->enumerateTopics([]( - not_null topic) { - MarkAsReadThread(topic); - }); - } else if (const auto history = thread->asHistory()) { - readHistory(history); - if (const auto migrated = history->migrateSibling()) { - readHistory(migrated); - } - } else if (const auto topic = thread->asTopic()) { - topic->readTillEnd(); - } -} - void MarkAsReadChatList(not_null list) { auto mark = std::vector>(); for (const auto &row : list->indexed()->all()) { @@ -2391,4 +2366,29 @@ bool FillVideoChatMenu( return has || manager; } +bool IsUnreadThread(not_null thread) { + return thread->chatListBadgesState().unread; +} + +void MarkAsReadThread(not_null thread) { + const auto readHistory = [&](not_null history) { + history->owner().histories().readInbox(history); + }; + if (!IsUnreadThread(thread)) { + return; + } else if (const auto forum = thread->asForum()) { + forum->enumerateTopics([]( + not_null topic) { + MarkAsReadThread(topic); + }); + } else if (const auto history = thread->asHistory()) { + readHistory(history); + if (const auto migrated = history->migrateSibling()) { + readHistory(migrated); + } + } else if (const auto topic = thread->asTopic()) { + topic->readTillEnd(); + } +} + } // namespace Window diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h index 63af72e5f..ebe249dd0 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.h +++ b/Telegram/SourceFiles/window/window_peer_menu.h @@ -161,4 +161,7 @@ void UnpinAllMessages( not_null navigation, not_null thread); +[[nodiscard]] bool IsUnreadThread(not_null thread); +void MarkAsReadThread(not_null thread); + } // namespace Window