2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 23:55:12 +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

@@ -193,7 +193,7 @@ InnerWidget::InnerWidget(
session().data().sendActionManager().speakingAnimationUpdated(
) | rpl::start_with_next([=](not_null<History*> history) {
updateDialogRowCornerStatus(history);
repaintDialogRowCornerStatus(history);
}, lifetime());
setupOnlineStatusCheck();
@@ -3181,15 +3181,15 @@ void InnerWidget::setupOnlineStatusCheck() {
Data::PeerUpdate::Flag::OnlineStatus
| Data::PeerUpdate::Flag::GroupCall
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
if (update.peer->isUser()) {
userOnlineUpdated(update.peer);
if (const auto user = update.peer->asUser()) {
userOnlineUpdated(user);
} else {
groupHasCallUpdated(update.peer);
}
}, lifetime());
}
void InnerWidget::updateDialogRowCornerStatus(not_null<History*> history) {
void InnerWidget::repaintDialogRowCornerStatus(not_null<History*> history) {
const auto user = history->peer->isUser();
const auto size = user
? st::dialogsOnlineBadgeSize
@@ -3217,16 +3217,15 @@ void InnerWidget::updateDialogRowCornerStatus(not_null<History*> history) {
UpdateRowSection::Default | UpdateRowSection::Filtered);
}
void InnerWidget::userOnlineUpdated(not_null<PeerData*> peer) {
const auto user = peer->isSelf() ? nullptr : peer->asUser();
if (!user) {
void InnerWidget::userOnlineUpdated(not_null<UserData*> user) {
if (!user->isSelf()) {
return;
}
const auto history = session().data().historyLoaded(user);
if (!history) {
return;
}
updateRowCornerStatusShown(history, Data::IsUserOnline(user));
updateRowCornerStatusShown(history);
}
void InnerWidget::groupHasCallUpdated(not_null<PeerData*> peer) {
@@ -3238,14 +3237,12 @@ void InnerWidget::groupHasCallUpdated(not_null<PeerData*> peer) {
if (!history) {
return;
}
updateRowCornerStatusShown(history, Data::ChannelHasActiveCall(group));
updateRowCornerStatusShown(history);
}
void InnerWidget::updateRowCornerStatusShown(
not_null<History*> history,
bool shown) {
void InnerWidget::updateRowCornerStatusShown(not_null<History*> history) {
const auto repaint = [=] {
updateDialogRowCornerStatus(history);
repaintDialogRowCornerStatus(history);
};
repaint();