mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-05 09:05:14 +00:00
Add voice chat indicator in the chats list.
This commit is contained in:
@@ -189,6 +189,11 @@ InnerWidget::InnerWidget(
|
||||
UpdateRowSection::Default | UpdateRowSection::Filtered);
|
||||
}, lifetime());
|
||||
|
||||
session().data().speakingAnimationUpdated(
|
||||
) | rpl::start_with_next([=](not_null<History*> history) {
|
||||
updateDialogRowCornerStatus(history);
|
||||
}, lifetime());
|
||||
|
||||
setupOnlineStatusCheck();
|
||||
|
||||
rpl::merge(
|
||||
@@ -2959,11 +2964,43 @@ MsgId InnerWidget::lastSearchMigratedId() const {
|
||||
void InnerWidget::setupOnlineStatusCheck() {
|
||||
session().changes().peerUpdates(
|
||||
Data::PeerUpdate::Flag::OnlineStatus
|
||||
| Data::PeerUpdate::Flag::GroupCall
|
||||
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
|
||||
userOnlineUpdated(update.peer);
|
||||
if (update.peer->isUser()) {
|
||||
userOnlineUpdated(update.peer);
|
||||
} else {
|
||||
groupHasCallUpdated(update.peer);
|
||||
}
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void InnerWidget::updateDialogRowCornerStatus(not_null<History*> history) {
|
||||
const auto user = history->peer->isUser();
|
||||
const auto size = user
|
||||
? st::dialogsOnlineBadgeSize
|
||||
: st::dialogsCallBadgeSize;
|
||||
const auto stroke = st::dialogsOnlineBadgeStroke;
|
||||
const auto skip = user
|
||||
? st::dialogsOnlineBadgeSkip
|
||||
: st::dialogsCallBadgeSkip;
|
||||
const auto updateRect = QRect(
|
||||
st::dialogsPhotoSize - skip.x() - size,
|
||||
st::dialogsPhotoSize - skip.y() - size,
|
||||
size,
|
||||
size
|
||||
).marginsAdded(
|
||||
{ stroke, stroke, stroke, stroke }
|
||||
).translated(
|
||||
st::dialogsPadding
|
||||
);
|
||||
updateDialogRow(
|
||||
RowDescriptor(
|
||||
history,
|
||||
FullMsgId()),
|
||||
updateRect,
|
||||
UpdateRowSection::Default | UpdateRowSection::Filtered);
|
||||
}
|
||||
|
||||
void InnerWidget::userOnlineUpdated(not_null<PeerData*> peer) {
|
||||
const auto user = peer->isSelf() ? nullptr : peer->asUser();
|
||||
if (!user) {
|
||||
@@ -2973,32 +3010,35 @@ void InnerWidget::userOnlineUpdated(not_null<PeerData*> peer) {
|
||||
if (!history) {
|
||||
return;
|
||||
}
|
||||
const auto size = st::dialogsOnlineBadgeSize;
|
||||
const auto stroke = st::dialogsOnlineBadgeStroke;
|
||||
const auto skip = st::dialogsOnlineBadgeSkip;
|
||||
const auto edge = st::dialogsPadding.x() + st::dialogsPhotoSize;
|
||||
const auto updateRect = QRect(
|
||||
edge - skip.x() - size,
|
||||
edge - skip.y() - size,
|
||||
size,
|
||||
size
|
||||
).marginsAdded(
|
||||
{ stroke, stroke, stroke, stroke }
|
||||
).translated(
|
||||
st::dialogsPadding
|
||||
);
|
||||
updateRowCornerStatusShown(
|
||||
history,
|
||||
Data::OnlineTextActive(user, base::unixtime::now()));
|
||||
}
|
||||
|
||||
void InnerWidget::groupHasCallUpdated(not_null<PeerData*> peer) {
|
||||
const auto group = peer->asMegagroup();
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
const auto history = session().data().historyLoaded(group);
|
||||
if (!history) {
|
||||
return;
|
||||
}
|
||||
updateRowCornerStatusShown(
|
||||
history,
|
||||
group->flags() & MTPDchannel::Flag::f_call_active);
|
||||
}
|
||||
|
||||
void InnerWidget::updateRowCornerStatusShown(
|
||||
not_null<History*> history,
|
||||
bool shown) {
|
||||
const auto repaint = [=] {
|
||||
updateDialogRow(
|
||||
RowDescriptor(
|
||||
history,
|
||||
FullMsgId()),
|
||||
updateRect,
|
||||
UpdateRowSection::Default | UpdateRowSection::Filtered);
|
||||
updateDialogRowCornerStatus(history);
|
||||
};
|
||||
repaint();
|
||||
|
||||
const auto findRow = [&](not_null<History*> history)
|
||||
-> std::pair<Row*, int> {
|
||||
-> std::pair<Row*, int> {
|
||||
if (state() == WidgetState::Default) {
|
||||
const auto row = shownDialogs()->getRow({ history });
|
||||
return { row, row ? defaultRowTop(row) : 0 };
|
||||
@@ -3014,8 +3054,8 @@ void InnerWidget::userOnlineUpdated(not_null<PeerData*> peer) {
|
||||
if (const auto &[row, top] = findRow(history); row != nullptr) {
|
||||
const auto visible = (top < _visibleBottom)
|
||||
&& (top + st::dialogsRowHeight > _visibleTop);
|
||||
row->setOnline(
|
||||
Data::OnlineTextActive(user, base::unixtime::now()),
|
||||
row->updateCornerBadgeShown(
|
||||
history->peer,
|
||||
visible ? Fn<void()>(crl::guard(this, repaint)) : nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user