2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Mark topics as read using Ctrl+R shortcut.

Fixes #25669.
This commit is contained in:
John Preston
2023-01-04 14:34:37 +04:00
parent eb0642f569
commit 9933c6ba59
3 changed files with 35 additions and 32 deletions

View File

@@ -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