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

Method reloadPromo

Telegram/SourceFiles/api/api_premium.cpp:167–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167void Premium::reloadPromo() {
168 if (_promoRequestId) {
169 return;
170 }
171 _promoRequestId = _api.request(MTPhelp_GetPremiumPromo(
172 )).done([=](const MTPhelp_PremiumPromo &result) {
173 _promoRequestId = 0;
174 const auto &data = result.data();
175 _session->data().processUsers(data.vusers());
176
177 _subscriptionOptions = PremiumSubscriptionOptionsFromTL(
178 data.vperiod_options().v);
179 for (const auto &option : data.vperiod_options().v) {
180 if (option.data().vmonths().v == 1) {
181 _monthlyAmount = option.data().vamount().v;
182 _monthlyCurrency = qs(option.data().vcurrency());
183 }
184 }
185 auto text = TextWithEntities{
186 qs(data.vstatus_text()),
187 EntitiesFromMTP(_session, data.vstatus_entities().v),
188 };
189 _statusText = text;
190 _statusTextUpdates.fire(std::move(text));
191 auto videos = base::flat_map<QString, not_null<DocumentData*>>();
192 const auto count = int(std::min(
193 data.vvideo_sections().v.size(),
194 data.vvideos().v.size()));
195 videos.reserve(count);
196 for (auto i = 0; i != count; ++i) {
197 const auto document = _session->data().processDocument(
198 data.vvideos().v[i]);
199 if ((!document->isVideoFile() && !document->isGifv())
200 || !document->supportsStreaming()) {
201 document->forceIsStreamedAnimation();
202 }
203 videos.emplace(
204 qs(data.vvideo_sections().v[i]),
205 document);
206 }
207 if (_videos != videos) {
208 _videos = std::move(videos);
209 _videosUpdated.fire({});
210 }
211 }).fail([=] {
212 _promoRequestId = 0;
213 }).send();
214}
215
216void Premium::reloadStickers() {
217 if (_stickersRequestId) {

Callers

nothing calls this directly

Calls 15

qsFunction · 0.85
EntitiesFromMTPFunction · 0.85
processUsersMethod · 0.80
processDocumentMethod · 0.80
supportsStreamingMethod · 0.80
emplaceMethod · 0.80
sendMethod · 0.45
failMethod · 0.45
doneMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected