| 165 | } |
| 166 | |
| 167 | void 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 | |
| 216 | void Premium::reloadStickers() { |
| 217 | if (_stickersRequestId) { |
nothing calls this directly
no test coverage detected