Show call button only when you can create voice chat.

This commit is contained in:
John Preston 2020-11-28 15:14:28 +03:00
parent 7cfb39ea5d
commit e66a72876c

View file

@ -127,12 +127,22 @@ TopBarWidget::TopBarWidget(
| UpdateFlag::OnlineStatus | UpdateFlag::OnlineStatus
| UpdateFlag::Members | UpdateFlag::Members
| UpdateFlag::SupportInfo | UpdateFlag::SupportInfo
| UpdateFlag::Rights
) | rpl::start_with_next([=](const Data::PeerUpdate &update) { ) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
if (update.flags & UpdateFlag::HasCalls) { if (update.flags & UpdateFlag::HasCalls) {
if (update.peer->isUser()) { if (update.peer->isUser()
&& (update.peer->isSelf()
|| _activeChat.key.peer() == update.peer)) {
updateControlsVisibility(); updateControlsVisibility();
} }
} else { } else if ((update.flags & UpdateFlag::Rights)
&& (_activeChat.key.peer() == update.peer)) {
updateControlsVisibility();
}
if (update.flags
& (UpdateFlag::OnlineStatus
| UpdateFlag::Members
| UpdateFlag::SupportInfo)) {
updateOnlineDisplay(); updateOnlineDisplay();
} }
}, lifetime()); }, lifetime());
@ -694,7 +704,7 @@ void TopBarWidget::updateControlsVisibility() {
return session().serverConfig().phoneCallsEnabled.current() return session().serverConfig().phoneCallsEnabled.current()
&& user->hasCalls(); && user->hasCalls();
} else if (const auto megagroup = peer->asMegagroup()) { } else if (const auto megagroup = peer->asMegagroup()) {
return true; return megagroup->canManageCall();
} }
} }
return false; return false;