From e66a72876c5676709540e318c51e6fd965e95d55 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 28 Nov 2020 15:14:28 +0300 Subject: [PATCH] Show call button only when you can create voice chat. --- .../history/view/history_view_top_bar_widget.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 1414db537..983025d41 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -127,12 +127,22 @@ TopBarWidget::TopBarWidget( | UpdateFlag::OnlineStatus | UpdateFlag::Members | UpdateFlag::SupportInfo + | UpdateFlag::Rights ) | rpl::start_with_next([=](const Data::PeerUpdate &update) { if (update.flags & UpdateFlag::HasCalls) { - if (update.peer->isUser()) { + if (update.peer->isUser() + && (update.peer->isSelf() + || _activeChat.key.peer() == update.peer)) { updateControlsVisibility(); } - } else { + } else if ((update.flags & UpdateFlag::Rights) + && (_activeChat.key.peer() == update.peer)) { + updateControlsVisibility(); + } + if (update.flags + & (UpdateFlag::OnlineStatus + | UpdateFlag::Members + | UpdateFlag::SupportInfo)) { updateOnlineDisplay(); } }, lifetime()); @@ -694,7 +704,7 @@ void TopBarWidget::updateControlsVisibility() { return session().serverConfig().phoneCallsEnabled.current() && user->hasCalls(); } else if (const auto megagroup = peer->asMegagroup()) { - return true; + return megagroup->canManageCall(); } } return false;