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

Method activate

Telegram/SourceFiles/main/main_domain.cpp:456–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454}
455
456void Domain::activate(not_null<Main::Account*> account) {
457 if (const auto window = Core::App().separateWindowFor(account)) {
458 window->activate();
459 }
460 if (_active.current() == account.get()) {
461 return;
462 }
463 const auto i = ranges::find(_accounts, account.get(), [](
464 const AccountWithIndex &value) {
465 return value.account.get();
466 });
467 Assert(i != end(_accounts));
468 const auto changed = (_accountToActivate != i->index);
469 auto wasAuthed = false;
470
471 _activeLifetime.destroy();
472 if (_active.current()) {
473 _lastActiveIndex = _accountToActivate;
474 wasAuthed = _active.current()->sessionExists();
475 }
476 _accountToActivate = i->index;
477 _active = account.get();
478 _active.current()->sessionValue(
479 ) | rpl::start_to_stream(_activeSessions, _activeLifetime);
480
481 if (changed) {
482 if (wasAuthed) {
483 scheduleWriteAccounts();
484 } else {
485 crl::on_main(&Core::App(), [=] {
486 removeRedundantAccounts();
487 });
488 }
489 }
490}
491
492void Domain::scheduleWriteAccounts() {
493 if (_writeAccountsScheduled) {

Callers 3

addActivatedMethod · 0.45
tryResolveWindowMethod · 0.45

Calls 7

AppClass · 0.85
separateWindowForMethod · 0.80
sessionExistsMethod · 0.80
sessionValueMethod · 0.80
currentMethod · 0.45
getMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected