diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index dd3177654e..88c4488970 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1939,6 +1939,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_group_call_leave_sure" = "Are you sure you want to leave this voice chat?"; "lng_group_call_leave_to_other_sure" = "Do you want to leave your active voice chat and join a voice chat in this group?"; "lng_group_call_create_sure" = "Do you really want to start a voice chat in this group?"; +"lng_group_call_create_sure_channel" = "Are you sure you want to start a voice chat in this channel as your personal account?"; +"lng_group_call_join_sure_personal" = "Are you sure you want to join this voice chat as your personal account?"; "lng_group_call_also_end" = "End voice chat"; "lng_group_call_settings_title" = "Settings"; "lng_group_call_invite" = "Invite Member"; diff --git a/Telegram/SourceFiles/calls/calls_choose_join_as.cpp b/Telegram/SourceFiles/calls/calls_choose_join_as.cpp index 295c02a664..aa02d788b6 100644 --- a/Telegram/SourceFiles/calls/calls_choose_join_as.cpp +++ b/Telegram/SourceFiles/calls/calls_choose_join_as.cpp @@ -163,6 +163,37 @@ void ChooseJoinAsBox( box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); } +[[nodiscard]] TextWithEntities CreateOrJoinConfirmation( + not_null peer, + ChooseJoinAsProcess::Context context, + bool joinAsAlreadyUsed) { + const auto existing = peer->groupCall(); + if (!existing) { + return { peer->isBroadcast() + ? tr::lng_group_call_create_sure_channel(tr::now) + : tr::lng_group_call_create_sure(tr::now) }; + } + const auto channel = peer->asChannel(); + const auto anonymouseAdmin = channel + && ((channel->isMegagroup() && channel->amAnonymous()) + || (channel->isBroadcast() + && (channel->amCreator() + || channel->hasAdminRights()))); + if (anonymouseAdmin && !joinAsAlreadyUsed) { + return { tr::lng_group_call_join_sure_personal(tr::now) }; + } else if (context != ChooseJoinAsProcess::Context::JoinWithConfirm) { + return {}; + } + const auto name = !existing->title().isEmpty() + ? existing->title() + : peer->name; + return tr::lng_group_call_join_confirm( + tr::now, + lt_chat, + Ui::Text::Bold(name), + Ui::Text::WithEntities); +} + } // namespace ChooseJoinAsProcess::~ChooseJoinAsProcess() { @@ -257,31 +288,27 @@ void ChooseJoinAsProcess::start( info.possibleJoinAs = std::move(list); const auto onlyByMe = (info.possibleJoinAs.size() == 1) - && (info.possibleJoinAs.front() == self) - && (!peer->isChannel() - || !peer->asChannel()->amAnonymous() - || (peer->isBroadcast() && !peer->canWrite())); + && (info.possibleJoinAs.front() == self); // We already joined this voice chat, just rejoin with the same. const auto byAlreadyUsed = selectedId - && (info.joinAs->id == selectedId); + && (info.joinAs->id == selectedId) + && (peer->groupCall() != nullptr); if (!changingJoinAsFrom && (onlyByMe || byAlreadyUsed)) { - if (context != Context::JoinWithConfirm) { + const auto confirmation = CreateOrJoinConfirmation( + peer, + context, + byAlreadyUsed); + if (confirmation.text.isEmpty()) { finish(info); return; } - const auto real = peer->groupCall(); - const auto name = (real && !real->title().isEmpty()) - ? real->title() - : peer->name; auto box = Box<::ConfirmBox>( - tr::lng_group_call_join_confirm( - tr::now, - lt_chat, - Ui::Text::Bold(name), - Ui::Text::WithEntities), - tr::lng_group_call_join(tr::now), + confirmation, + (peer->groupCall() + ? tr::lng_group_call_join(tr::now) + : tr::lng_create_group_create(tr::now)), crl::guard(&_request->guard, [=] { finish(info); })); box->boxClosing( ) | rpl::start_with_next([=] {