2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Update API scheme on layer 148.

Extract message history corner buttons code.
This commit is contained in:
John Preston
2022-10-08 15:14:38 +04:00
parent 2c0b5b3210
commit 6a7f030ee7
24 changed files with 751 additions and 444 deletions

View File

@@ -700,6 +700,18 @@ not_null<HistoryItem*> History::addNewLocalMessage(
}
void History::clearUnreadMentionsFor(MsgId topicRootId) {
const auto forum = peer->forum();
if (!topicRootId) {
if (forum) {
forum->clearAllUnreadMentions();
}
unreadMentions().clear();
return;
} else if (forum) {
if (const auto topic = forum->topicFor(topicRootId)) {
topic->unreadMentions().clear();
}
}
const auto &ids = unreadMentionsIds();
if (ids.empty()) {
return;
@@ -720,6 +732,39 @@ void History::clearUnreadMentionsFor(MsgId topicRootId) {
}
}
void History::clearUnreadReactionsFor(MsgId topicRootId) {
const auto forum = peer->forum();
if (!topicRootId) {
if (forum) {
forum->clearAllUnreadReactions();
}
unreadReactions().clear();
return;
} else if (forum) {
if (const auto topic = forum->topicFor(topicRootId)) {
topic->unreadReactions().clear();
}
}
const auto &ids = unreadReactionsIds();
if (ids.empty()) {
return;
}
const auto owner = &this->owner();
const auto peerId = peer->id;
auto items = base::flat_set<MsgId>();
items.reserve(ids.size());
for (const auto &id : ids) {
if (const auto item = owner->message(peerId, id)) {
if (item->topicRootId() == topicRootId) {
items.emplace(id);
}
}
}
for (const auto &id : items) {
unreadReactions().erase(id);
}
}
not_null<HistoryItem*> History::addNewToBack(
not_null<HistoryItem*> item,
bool unread) {