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

Method checkLockByTerms

Telegram/SourceFiles/window/window_controller.cpp:248–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248void Controller::checkLockByTerms() {
249 const auto data = account().sessionExists()
250 ? account().session().termsLocked()
251 : std::nullopt;
252 if (!data) {
253 if (_termsBox) {
254 _termsBox->closeBox();
255 }
256 return;
257 }
258 hideSettingsAndLayer(anim::type::instant);
259 const auto box = show(Box<TermsBox>(
260 *data,
261 tr::lng_terms_agree(),
262 tr::lng_terms_decline()));
263
264 box->setCloseByEscape(false);
265 box->setCloseByOutsideClick(false);
266
267 const auto id = data->id;
268 box->agreeClicks(
269 ) | rpl::on_next([=] {
270 const auto mention = box ? box->lastClickedMention() : QString();
271 box->closeBox();
272 if (const auto session = account().maybeSession()) {
273 session->api().acceptTerms(id);
274 session->unlockTerms();
275 if (!mention.isEmpty()) {
276 MentionClickHandler(mention).onClick({});
277 }
278 }
279 }, box->lifetime());
280
281 box->cancelClicks(
282 ) | rpl::on_next([=] {
283 showTermsDecline();
284 }, box->lifetime());
285
286 QObject::connect(box.get(), &QObject::destroyed, [=] {
287 crl::on_main(widget(), [=] { checkLockByTerms(); });
288 });
289
290 _termsBox = box;
291}
292
293void Controller::showTermsDecline() {
294 const auto box = show(Box<Window::TermsBox>(

Callers

nothing calls this directly

Calls 15

showFunction · 0.85
MentionClickHandlerClass · 0.85
sessionExistsMethod · 0.80
termsLockedMethod · 0.80
agreeClicksMethod · 0.80
lastClickedMentionMethod · 0.80
apiMethod · 0.80
unlockTermsMethod · 0.80
QStringClass · 0.50
sessionMethod · 0.45
maybeSessionMethod · 0.45
acceptTermsMethod · 0.45

Tested by

no test coverage detected