mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replaced args for Calls::Instance::startOrJoinGroupCall with struct.
This commit is contained in:
parent
f2f4f9b24b
commit
a3d00b1953
7 changed files with 36 additions and 27 deletions
|
@ -200,9 +200,9 @@ void Instance::startOutgoingCall(not_null<UserData*> user, bool video) {
|
||||||
|
|
||||||
void Instance::startOrJoinGroupCall(
|
void Instance::startOrJoinGroupCall(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const QString &joinHash,
|
const StartGroupCallArgs &args) {
|
||||||
bool confirmNeeded) {
|
using JoinConfirm = StartGroupCallArgs::JoinConfirm;
|
||||||
const auto context = confirmNeeded
|
const auto context = (args.confirm == JoinConfirm::Always)
|
||||||
? Group::ChooseJoinAsProcess::Context::JoinWithConfirm
|
? Group::ChooseJoinAsProcess::Context::JoinWithConfirm
|
||||||
: peer->groupCall()
|
: peer->groupCall()
|
||||||
? Group::ChooseJoinAsProcess::Context::Join
|
? Group::ChooseJoinAsProcess::Context::Join
|
||||||
|
@ -213,7 +213,7 @@ void Instance::startOrJoinGroupCall(
|
||||||
Ui::Toast::Show(text);
|
Ui::Toast::Show(text);
|
||||||
}, [=](Group::JoinInfo info) {
|
}, [=](Group::JoinInfo info) {
|
||||||
const auto call = info.peer->groupCall();
|
const auto call = info.peer->groupCall();
|
||||||
info.joinHash = joinHash;
|
info.joinHash = args.joinHash;
|
||||||
if (call) {
|
if (call) {
|
||||||
info.rtmp = call->rtmp();
|
info.rtmp = call->rtmp();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,18 @@ class GroupCall;
|
||||||
class Panel;
|
class Panel;
|
||||||
struct DhConfig;
|
struct DhConfig;
|
||||||
|
|
||||||
|
struct StartGroupCallArgs {
|
||||||
|
enum class JoinConfirm {
|
||||||
|
None,
|
||||||
|
IfNowInAnother,
|
||||||
|
Always,
|
||||||
|
};
|
||||||
|
QString joinHash;
|
||||||
|
JoinConfirm confirm = JoinConfirm::IfNowInAnother;
|
||||||
|
bool scheduleNeeded = false;
|
||||||
|
bool rtmp = false;
|
||||||
|
};
|
||||||
|
|
||||||
class Instance final : public base::has_weak_ptr {
|
class Instance final : public base::has_weak_ptr {
|
||||||
public:
|
public:
|
||||||
Instance();
|
Instance();
|
||||||
|
@ -51,8 +63,7 @@ public:
|
||||||
void startOutgoingCall(not_null<UserData*> user, bool video);
|
void startOutgoingCall(not_null<UserData*> user, bool video);
|
||||||
void startOrJoinGroupCall(
|
void startOrJoinGroupCall(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const QString &joinHash = QString(),
|
const StartGroupCallArgs &args);
|
||||||
bool confirmNeeded = false);
|
|
||||||
void handleUpdate(
|
void handleUpdate(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const MTPUpdate &update);
|
const MTPUpdate &update);
|
||||||
|
|
|
@ -97,7 +97,7 @@ using ItemPreview = HistoryView::ItemPreview;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windows.front()->startOrJoinGroupCall(peer);
|
windows.front()->startOrJoinGroupCall(peer, {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6346,7 +6346,7 @@ void HistoryWidget::setupGroupCallBar() {
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
const auto peer = _history->peer;
|
const auto peer = _history->peer;
|
||||||
if (peer->groupCall()) {
|
if (peer->groupCall()) {
|
||||||
controller()->startOrJoinGroupCall(peer);
|
controller()->startOrJoinGroupCall(peer, {});
|
||||||
}
|
}
|
||||||
}, _groupCallBar->lifetime());
|
}, _groupCallBar->lifetime());
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ void TopBarWidget::call() {
|
||||||
|
|
||||||
void TopBarWidget::groupCall() {
|
void TopBarWidget::groupCall() {
|
||||||
if (const auto peer = _activeChat.key.peer()) {
|
if (const auto peer = _activeChat.key.peer()) {
|
||||||
_controller->startOrJoinGroupCall(peer);
|
_controller->startOrJoinGroupCall(peer, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -282,8 +282,7 @@ void SessionNavigation::showPeerByLinkResolved(
|
||||||
const auto join = [=] {
|
const auto join = [=] {
|
||||||
parentController()->startOrJoinGroupCall(
|
parentController()->startOrJoinGroupCall(
|
||||||
peer,
|
peer,
|
||||||
hash,
|
{ hash, Calls::StartGroupCallArgs::JoinConfirm::Always });
|
||||||
SessionController::GroupCallJoinConfirm::Always);
|
|
||||||
};
|
};
|
||||||
if (call->loaded()) {
|
if (call->loaded()) {
|
||||||
join();
|
join();
|
||||||
|
@ -1124,16 +1123,18 @@ void SessionController::showPeer(not_null<PeerData*> peer, MsgId msgId) {
|
||||||
|
|
||||||
void SessionController::startOrJoinGroupCall(
|
void SessionController::startOrJoinGroupCall(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
QString joinHash,
|
const Calls::StartGroupCallArgs &args) {
|
||||||
GroupCallJoinConfirm confirm) {
|
using JoinConfirm = Calls::StartGroupCallArgs::JoinConfirm;
|
||||||
auto &calls = Core::App().calls();
|
auto &calls = Core::App().calls();
|
||||||
const auto askConfirmation = [&](QString text, QString button) {
|
const auto askConfirmation = [&](QString text, QString button) {
|
||||||
show(Box<Ui::ConfirmBox>(text, button, crl::guard(this, [=] {
|
show(Box<Ui::ConfirmBox>(text, button, crl::guard(this, [=] {
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
startOrJoinGroupCall(peer, joinHash, GroupCallJoinConfirm::None);
|
startOrJoinGroupCall(
|
||||||
|
peer,
|
||||||
|
{ args.joinHash, JoinConfirm::None });
|
||||||
})));
|
})));
|
||||||
};
|
};
|
||||||
if (confirm != GroupCallJoinConfirm::None && calls.inCall()) {
|
if (args.confirm != JoinConfirm::None && calls.inCall()) {
|
||||||
// Do you want to leave your active voice chat
|
// Do you want to leave your active voice chat
|
||||||
// to join a voice chat in this group?
|
// to join a voice chat in this group?
|
||||||
askConfirmation(
|
askConfirmation(
|
||||||
|
@ -1141,13 +1142,13 @@ void SessionController::startOrJoinGroupCall(
|
||||||
? tr::lng_call_leave_to_other_sure_channel
|
? tr::lng_call_leave_to_other_sure_channel
|
||||||
: tr::lng_call_leave_to_other_sure)(tr::now),
|
: tr::lng_call_leave_to_other_sure)(tr::now),
|
||||||
tr::lng_call_bar_hangup(tr::now));
|
tr::lng_call_bar_hangup(tr::now));
|
||||||
} else if (confirm != GroupCallJoinConfirm::None
|
} else if (args.confirm != JoinConfirm::None
|
||||||
&& calls.inGroupCall()) {
|
&& calls.inGroupCall()) {
|
||||||
const auto now = calls.currentGroupCall()->peer();
|
const auto now = calls.currentGroupCall()->peer();
|
||||||
if (now == peer) {
|
if (now == peer) {
|
||||||
calls.activateCurrentCall(joinHash);
|
calls.activateCurrentCall(args.joinHash);
|
||||||
} else if (calls.currentGroupCall()->scheduleDate()) {
|
} else if (calls.currentGroupCall()->scheduleDate()) {
|
||||||
calls.startOrJoinGroupCall(peer, joinHash);
|
calls.startOrJoinGroupCall(peer, { args.joinHash });
|
||||||
} else {
|
} else {
|
||||||
askConfirmation(
|
askConfirmation(
|
||||||
((peer->isBroadcast() && now->isBroadcast())
|
((peer->isBroadcast() && now->isBroadcast())
|
||||||
|
@ -1160,8 +1161,7 @@ void SessionController::startOrJoinGroupCall(
|
||||||
tr::lng_group_call_leave(tr::now));
|
tr::lng_group_call_leave(tr::now));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto confirmNeeded = (confirm == GroupCallJoinConfirm::Always);
|
calls.startOrJoinGroupCall(peer, args);
|
||||||
calls.startOrJoinGroupCall(peer, joinHash, confirmNeeded);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,10 @@ namespace Settings {
|
||||||
enum class Type;
|
enum class Type;
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
|
|
||||||
|
namespace Calls {
|
||||||
|
struct StartGroupCallArgs;
|
||||||
|
} // namespace Calls
|
||||||
|
|
||||||
namespace Passport {
|
namespace Passport {
|
||||||
struct FormRequest;
|
struct FormRequest;
|
||||||
class FormController;
|
class FormController;
|
||||||
|
@ -339,15 +343,9 @@ public:
|
||||||
|
|
||||||
void showPeer(not_null<PeerData*> peer, MsgId msgId = ShowAtUnreadMsgId);
|
void showPeer(not_null<PeerData*> peer, MsgId msgId = ShowAtUnreadMsgId);
|
||||||
|
|
||||||
enum class GroupCallJoinConfirm {
|
|
||||||
None,
|
|
||||||
IfNowInAnother,
|
|
||||||
Always,
|
|
||||||
};
|
|
||||||
void startOrJoinGroupCall(
|
void startOrJoinGroupCall(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
QString joinHash = QString(),
|
const Calls::StartGroupCallArgs &args);
|
||||||
GroupCallJoinConfirm confirm = GroupCallJoinConfirm::IfNowInAnother);
|
|
||||||
|
|
||||||
void showSection(
|
void showSection(
|
||||||
std::shared_ptr<SectionMemento> memento,
|
std::shared_ptr<SectionMemento> memento,
|
||||||
|
|
Loading…
Add table
Reference in a new issue