mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-02 23:45:44 +00:00
@@ -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);
|
||||
const auto thread = _selected ? _selected->thread() : nullptr;
|
||||
if (!thread) {
|
||||
return false;
|
||||
}
|
||||
if (Window::IsUnreadThread(thread)) {
|
||||
Window::MarkAsReadThread(thread);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return (history != nullptr);
|
||||
});
|
||||
|
||||
request->check(Command::ShowContacts) && request->handle([=] {
|
||||
|
@@ -161,31 +161,6 @@ void SetActionText(not_null<QAction*> action, rpl::producer<QString> &&text) {
|
||||
}, *lifetime);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsUnreadThread(not_null<Data::Thread*> thread) {
|
||||
return thread->chatListBadgesState().unread;
|
||||
}
|
||||
|
||||
void MarkAsReadThread(not_null<Data::Thread*> thread) {
|
||||
const auto readHistory = [&](not_null<History*> history) {
|
||||
history->owner().histories().readInbox(history);
|
||||
};
|
||||
if (!IsUnreadThread(thread)) {
|
||||
return;
|
||||
} else if (const auto forum = thread->asForum()) {
|
||||
forum->enumerateTopics([](
|
||||
not_null<Data::ForumTopic*> 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<Dialogs::MainList*> list) {
|
||||
auto mark = std::vector<not_null<History*>>();
|
||||
for (const auto &row : list->indexed()->all()) {
|
||||
@@ -2391,4 +2366,29 @@ bool FillVideoChatMenu(
|
||||
return has || manager;
|
||||
}
|
||||
|
||||
bool IsUnreadThread(not_null<Data::Thread*> thread) {
|
||||
return thread->chatListBadgesState().unread;
|
||||
}
|
||||
|
||||
void MarkAsReadThread(not_null<Data::Thread*> thread) {
|
||||
const auto readHistory = [&](not_null<History*> history) {
|
||||
history->owner().histories().readInbox(history);
|
||||
};
|
||||
if (!IsUnreadThread(thread)) {
|
||||
return;
|
||||
} else if (const auto forum = thread->asForum()) {
|
||||
forum->enumerateTopics([](
|
||||
not_null<Data::ForumTopic*> 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
|
||||
|
@@ -161,4 +161,7 @@ void UnpinAllMessages(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<Data::Thread*> thread);
|
||||
|
||||
[[nodiscard]] bool IsUnreadThread(not_null<Data::Thread*> thread);
|
||||
void MarkAsReadThread(not_null<Data::Thread*> thread);
|
||||
|
||||
} // namespace Window
|
||||
|
Reference in New Issue
Block a user