MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / sendPollRequests

Method sendPollRequests

Telegram/SourceFiles/api/api_views.cpp:114–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void ViewsManager::sendPollRequests() {
115 const auto now = crl::now();
116 auto toRequest = base::flat_map<not_null<PeerData*>, QVector<MTPint>>();
117 auto nearest = crl::time();
118 for (auto &[peer, request] : _pollRequests) {
119 if (request.id) {
120 continue;
121 } else if (request.when <= now) {
122 Assert(request.sent.empty());
123 auto &list = toRequest[peer];
124 const auto count = int(request.ids.size());
125 if (count < kMaxPollPerRequest) {
126 request.sent = base::take(request.ids);
127 } else {
128 const auto from = begin(request.ids);
129 const auto end = from + kMaxPollPerRequest;
130 request.sent = { from, end };
131 request.ids.erase(from, end);
132 }
133 list.reserve(request.sent.size());
134 for (const auto &id : request.sent) {
135 list.push_back(MTP_int(id.bare));
136 }
137 if (!request.ids.empty()) {
138 nearest = now;
139 }
140 } else if (!nearest || nearest > request.when) {
141 nearest = request.when;
142 }
143 }
144 sendPollRequests(toRequest);
145 if (nearest) {
146 _pollTimer.callOnce(std::max(nearest - now, crl::time(1)));
147 }
148}
149
150void ViewsManager::sendPollRequests(
151 const base::flat_map<

Callers

nothing calls this directly

Calls 15

requestItemRepaintMethod · 0.80
apiMethod · 0.80
MTP_intFunction · 0.50
finishFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
dataMethod · 0.45
messageMethod · 0.45
clearMethod · 0.45
isActiveMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected