mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Always join voice chats by link with confirmation.
This commit is contained in:
@@ -12,12 +12,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_group_call.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_account.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "apiwrap.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "boxes/peer_list_box.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_calls.h"
|
||||
|
||||
@@ -114,7 +117,8 @@ void ChooseJoinAsBox(
|
||||
box->setTitle([&] {
|
||||
switch (context) {
|
||||
case Context::Create: return tr::lng_group_call_start_as_header();
|
||||
case Context::Join: return tr::lng_group_call_join_as_header();
|
||||
case Context::Join:
|
||||
case Context::JoinWithConfirm: return tr::lng_group_call_join_as_header();
|
||||
case Context::Switch: return tr::lng_group_call_display_as_header();
|
||||
}
|
||||
Unexpected("Context in ChooseJoinAsBox.");
|
||||
@@ -231,19 +235,43 @@ void ChooseJoinAsProcess::start(
|
||||
}
|
||||
return list;
|
||||
});
|
||||
const auto selectedId = peer->groupCallDefaultJoinAs();
|
||||
if (list.empty()) {
|
||||
_request->showToast(Lang::Hard::ServerError());
|
||||
return;
|
||||
} else if (list.size() == 1
|
||||
} else if (!changingJoinAsFrom
|
||||
&& list.size() == 1
|
||||
&& list.front() == self
|
||||
&& (!peer->isChannel()
|
||||
|| !peer->asChannel()->amAnonymous()
|
||||
|| (peer->isBroadcast() && !peer->canWrite()))) {
|
||||
info.possibleJoinAs = std::move(list);
|
||||
finish(info);
|
||||
if (context != Context::JoinWithConfirm
|
||||
|| (selectedId && self->id == selectedId)) {
|
||||
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),
|
||||
crl::guard(&_request->guard, [=] { finish(info); }));
|
||||
box->boxClosing(
|
||||
) | rpl::start_with_next([=] {
|
||||
_request = nullptr;
|
||||
}, _request->lifetime);
|
||||
|
||||
_request->box = box.data();
|
||||
_request->showBox(std::move(box));
|
||||
return;
|
||||
}
|
||||
const auto selectedId = peer->groupCallDefaultJoinAs();
|
||||
info.joinAs = [&]() -> not_null<PeerData*> {
|
||||
const auto loaded = selectedId
|
||||
? session->data().peerLoaded(selectedId)
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
enum class Context {
|
||||
Create,
|
||||
Join,
|
||||
JoinWithConfirm,
|
||||
Switch,
|
||||
};
|
||||
|
||||
|
||||
@@ -302,8 +302,8 @@ Panel::Panel(not_null<GroupCall*> call)
|
||||
.text = tr::lng_group_call_can_speak(
|
||||
tr::now,
|
||||
lt_chat,
|
||||
Ui::Text::WithEntities(name),
|
||||
Ui::Text::RichLangValue),
|
||||
Ui::Text::Bold(name),
|
||||
Ui::Text::WithEntities),
|
||||
.st = &st::defaultToast,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -531,8 +531,8 @@ void SettingsBox(
|
||||
&& peer->asChannel()->hasUsername()
|
||||
&& goodReal) {
|
||||
const auto showBox = crl::guard(box, [=](
|
||||
object_ptr<Ui::BoxContent> box) {
|
||||
box->getDelegate()->show(std::move(box));
|
||||
object_ptr<Ui::BoxContent> next) {
|
||||
box->getDelegate()->show(std::move(next));
|
||||
});
|
||||
const auto showToast = crl::guard(box, [=](QString text) {
|
||||
Ui::Toast::Show(
|
||||
|
||||
@@ -65,8 +65,11 @@ void Instance::startOutgoingCall(not_null<UserData*> user, bool video) {
|
||||
|
||||
void Instance::startOrJoinGroupCall(
|
||||
not_null<PeerData*> peer,
|
||||
const QString &joinHash) {
|
||||
const auto context = peer->groupCall()
|
||||
const QString &joinHash,
|
||||
bool confirmNeeded) {
|
||||
const auto context = confirmNeeded
|
||||
? Group::ChooseJoinAsProcess::Context::JoinWithConfirm
|
||||
: peer->groupCall()
|
||||
? Group::ChooseJoinAsProcess::Context::Join
|
||||
: Group::ChooseJoinAsProcess::Context::Create;
|
||||
_chooseJoinAs.start(peer, context, [=](object_ptr<Ui::BoxContent> box) {
|
||||
|
||||
@@ -45,7 +45,8 @@ public:
|
||||
void startOutgoingCall(not_null<UserData*> user, bool video);
|
||||
void startOrJoinGroupCall(
|
||||
not_null<PeerData*> peer,
|
||||
const QString &joinHash = QString());
|
||||
const QString &joinHash = QString(),
|
||||
bool confirmNeeded = false);
|
||||
void handleUpdate(
|
||||
not_null<Main::Session*> session,
|
||||
const MTPUpdate &update);
|
||||
|
||||
Reference in New Issue
Block a user