Merge tag 'v6.7.2' into dev

This commit is contained in:
AlexeyZavar
2026-04-04 05:27:01 +03:00
592 changed files with 35740 additions and 5632 deletions
@@ -59,6 +59,13 @@ bool UnreadThings::trackReactions(Data::Thread *thread) const {
return peer->isUser() || peer->isChat() || peer->isMegagroup();
}
bool UnreadThings::trackPollVotes(Data::Thread *thread) const {
const auto peer = thread ? thread->peer().get() : nullptr;
return peer
&& (peer->isChat() || peer->isMegagroup())
&& !peer->isMonoforum();
}
void UnreadThings::preloadEnough(Data::Thread *thread) {
if (trackMentions(thread)) {
preloadEnoughMentions(thread);
@@ -66,6 +73,9 @@ void UnreadThings::preloadEnough(Data::Thread *thread) {
if (trackReactions(thread)) {
preloadEnoughReactions(thread);
}
if (trackPollVotes(thread)) {
preloadEnoughPollVotes(thread);
}
}
void UnreadThings::mediaAndMentionsRead(
@@ -101,6 +111,15 @@ void UnreadThings::preloadEnoughReactions(not_null<Data::Thread*> thread) {
}
}
void UnreadThings::preloadEnoughPollVotes(not_null<Data::Thread*> thread) {
const auto fullCount = thread->unreadPollVotes().count();
const auto loadedCount = thread->unreadPollVotes().loadedCount();
const auto allLoaded = (fullCount >= 0) && (loadedCount >= fullCount);
if (fullCount >= 0 && loadedCount < kPreloadIfLess && !allLoaded) {
requestPollVotes(thread, loadedCount);
}
}
void UnreadThings::cancelRequests(not_null<Data::Thread*> thread) {
if (const auto requestId = _mentionsRequests.take(thread)) {
_api->request(*requestId).cancel();
@@ -108,6 +127,9 @@ void UnreadThings::cancelRequests(not_null<Data::Thread*> thread) {
if (const auto requestId = _reactionsRequests.take(thread)) {
_api->request(*requestId).cancel();
}
if (const auto requestId = _pollVotesRequests.take(thread)) {
_api->request(*requestId).cancel();
}
}
void UnreadThings::requestMentions(
@@ -181,4 +203,38 @@ void UnreadThings::requestReactions(
_reactionsRequests.emplace(thread, requestId);
}
void UnreadThings::requestPollVotes(
not_null<Data::Thread*> thread,
int loaded) {
if (_pollVotesRequests.contains(thread) || thread->asSublist()) {
return;
}
const auto offsetId = loaded
? std::max(thread->unreadPollVotes().maxLoaded(), MsgId(1))
: MsgId(1);
const auto limit = loaded ? kNextRequestLimit : kFirstRequestLimit;
const auto addOffset = loaded ? -(limit + 1) : -limit;
const auto maxId = 0;
const auto minId = 0;
const auto history = thread->owningHistory();
const auto topic = thread->asTopic();
using Flag = MTPmessages_GetUnreadPollVotes::Flag;
const auto requestId = _api->request(MTPmessages_GetUnreadPollVotes(
MTP_flags(topic ? Flag::f_top_msg_id : Flag()),
history->peer->input(),
MTP_int(topic ? topic->rootId() : 0),
MTP_int(offsetId),
MTP_int(addOffset),
MTP_int(limit),
MTP_int(maxId),
MTP_int(minId)
)).done([=](const MTPmessages_Messages &result) {
_pollVotesRequests.remove(thread);
thread->unreadPollVotes().addSlice(result, loaded);
}).fail([=] {
_pollVotesRequests.remove(thread);
}).send();
_pollVotesRequests.emplace(thread, requestId);
}
} // namespace UnreadThings