2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Track dialog row offline status by timer.

Fixes #6410.
This commit is contained in:
John Preston
2022-10-24 11:22:26 +04:00
parent 0cba9e4a22
commit ed895ace66
10 changed files with 104 additions and 26 deletions

View File

@@ -15,10 +15,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "dialogs/ui/dialogs_video_userpic.h"
#include "dialogs/ui/dialogs_layout.h"
#include "data/data_folder.h"
#include "data/data_session.h"
#include "data/data_peer_values.h"
#include "history/history.h"
#include "history/history_item.h"
#include "lang/lang_keys.h"
#include "base/unixtime.h"
#include "mainwidget.h"
#include "styles/style_dialogs.h"
@@ -196,15 +198,20 @@ void Row::setCornerBadgeShown(
void Row::updateCornerBadgeShown(
not_null<PeerData*> peer,
Fn<void()> updateCallback) const {
const auto user = peer->asUser();
const auto now = user ? base::unixtime::now() : TimeId();
const auto shown = [&] {
if (const auto user = peer->asUser()) {
return Data::IsUserOnline(user);
if (user) {
return Data::IsUserOnline(user, now);
} else if (const auto channel = peer->asChannel()) {
return Data::ChannelHasActiveCall(channel);
}
return false;
}();
setCornerBadgeShown(shown, std::move(updateCallback));
if (shown && user) {
peer->owner().watchForOffline(user, now);
}
}
void Row::ensureCornerBadgeUserpic() const {