mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Don't ask joinAs for voice chats each time.
This commit is contained in:
parent
5d16359a5a
commit
c65c554d88
3 changed files with 21 additions and 9 deletions
|
@ -172,7 +172,7 @@ void ChooseJoinAsProcess::start(
|
|||
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
||||
Fn<void(QString)> showToast,
|
||||
Fn<void(JoinInfo)> done,
|
||||
PeerData *currentJoinAs) {
|
||||
PeerData *changingJoinAsFrom) {
|
||||
Expects(done != nullptr);
|
||||
|
||||
const auto session = &peer->session();
|
||||
|
@ -243,14 +243,14 @@ void ChooseJoinAsProcess::start(
|
|||
finish(info);
|
||||
return;
|
||||
}
|
||||
const auto selectedId = peer->groupCallDefaultJoinAs();
|
||||
info.joinAs = [&]() -> not_null<PeerData*> {
|
||||
const auto selectedId = peer->groupCallDefaultJoinAs();
|
||||
if (!selectedId) {
|
||||
return self;
|
||||
}
|
||||
const auto loaded = session->data().peerLoaded(selectedId);
|
||||
return (currentJoinAs && ranges::contains(list, not_null{ currentJoinAs }))
|
||||
? not_null(currentJoinAs)
|
||||
const auto loaded = selectedId
|
||||
? session->data().peerLoaded(selectedId)
|
||||
: nullptr;
|
||||
return (changingJoinAsFrom
|
||||
&& ranges::contains(list, not_null{ changingJoinAsFrom }))
|
||||
? not_null(changingJoinAsFrom)
|
||||
: (loaded && ranges::contains(list, not_null{ loaded }))
|
||||
? not_null(loaded)
|
||||
: ranges::contains(list, self)
|
||||
|
@ -259,6 +259,13 @@ void ChooseJoinAsProcess::start(
|
|||
}();
|
||||
info.possibleJoinAs = std::move(list);
|
||||
|
||||
if (!changingJoinAsFrom
|
||||
&& selectedId
|
||||
&& info.joinAs->id == selectedId) {
|
||||
// We already joined this voice chat, just rejoin with the same.
|
||||
finish(info);
|
||||
return;
|
||||
}
|
||||
auto box = Box(
|
||||
ChooseJoinAsBox,
|
||||
context,
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
||||
Fn<void(QString)> showToast,
|
||||
Fn<void(JoinInfo)> done,
|
||||
PeerData *currentJoinAs = nullptr);
|
||||
PeerData *changingJoinAsFrom = nullptr);
|
||||
|
||||
private:
|
||||
struct ChannelsListRequest {
|
||||
|
|
|
@ -426,6 +426,11 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
|
|||
LOG(("Call Info: Requesting join payload."));
|
||||
|
||||
_joinAs = as;
|
||||
if (const auto chat = _peer->asChat()) {
|
||||
chat->setGroupCallDefaultJoinAs(_joinAs->id);
|
||||
} else if (const auto channel = _peer->asChannel()) {
|
||||
channel->setGroupCallDefaultJoinAs(_joinAs->id);
|
||||
}
|
||||
|
||||
const auto weak = base::make_weak(this);
|
||||
_instance->emitJoinPayload([=](tgcalls::GroupJoinPayload payload) {
|
||||
|
|
Loading…
Add table
Reference in a new issue