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

Method watchForOffline

Telegram/SourceFiles/data/data_session.cpp:1333–1357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1331}
1332
1333void Session::watchForOffline(not_null<UserData*> user, TimeId now) {
1334 if (!now) {
1335 now = base::unixtime::now();
1336 }
1337 if (!Data::IsUserOnline(user, now)) {
1338 return;
1339 }
1340 const auto lastseen = user->lastseen();
1341 const auto till = lastseen.onlineTill();
1342 const auto &[i, ok] = _watchingForOffline.emplace(user, till);
1343 if (!ok) {
1344 if (i->second == till) {
1345 return;
1346 }
1347 i->second = till;
1348 }
1349 const auto timeout = Data::OnlineChangeTimeout(lastseen, now);
1350 const auto fires = _watchForOfflineTimer.isActive()
1351 ? _watchForOfflineTimer.remainingTime()
1352 : -1;
1353 if (fires >= 0 && fires <= timeout) {
1354 return;
1355 }
1356 _watchForOfflineTimer.callOnce(std::max(timeout, crl::time(1)));
1357}
1358
1359void Session::maybeStopWatchForOffline(not_null<UserData*> user) {
1360 if (Data::IsUserOnline(user)) {

Callers 2

TopPeersContentFunction · 0.80

Calls 6

IsUserOnlineFunction · 0.85
OnlineChangeTimeoutFunction · 0.85
lastseenMethod · 0.80
onlineTillMethod · 0.80
emplaceMethod · 0.80
isActiveMethod · 0.45

Tested by

no test coverage detected