mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix joining a voice chat.
This commit is contained in:
parent
1291f1c80d
commit
67623072d6
4 changed files with 130 additions and 102 deletions
|
@ -713,8 +713,16 @@ void GroupCall::setMutedAndUpdate(MuteState mute) {
|
|||
}
|
||||
}
|
||||
|
||||
void GroupCall::handleUpdate(const MTPGroupCall &call) {
|
||||
return call.match([&](const MTPDgroupCall &data) {
|
||||
void GroupCall::handlePossibleCreateOrJoinResponse(
|
||||
const MTPDupdateGroupCall &data) {
|
||||
data.vcall().match([&](const MTPDgroupCall &data) {
|
||||
handlePossibleCreateOrJoinResponse(data);
|
||||
}, [](const MTPDgroupCallDiscarded &data) {
|
||||
});
|
||||
}
|
||||
|
||||
void GroupCall::handlePossibleCreateOrJoinResponse(
|
||||
const MTPDgroupCall &data) {
|
||||
if (_acceptFields) {
|
||||
if (!_instance && !_id) {
|
||||
join(MTP_inputGroupCall(data.vid(), data.vaccess_hash()));
|
||||
|
@ -727,7 +735,10 @@ void GroupCall::handleUpdate(const MTPGroupCall &call) {
|
|||
}
|
||||
const auto streamDcId = MTP::BareDcId(
|
||||
data.vstream_dc_id().value_or_empty());
|
||||
if (const auto params = data.vparams()) {
|
||||
const auto params = data.vparams();
|
||||
if (!params) {
|
||||
return;
|
||||
}
|
||||
params->match([&](const MTPDdataJSON &data) {
|
||||
auto error = QJsonParseError{ 0, QJsonParseError::NoError };
|
||||
const auto document = QJsonDocument::fromJson(
|
||||
|
@ -800,13 +811,6 @@ void GroupCall::handleUpdate(const MTPGroupCall &call) {
|
|||
_instance->setJoinResponsePayload(payload, {});
|
||||
});
|
||||
}
|
||||
}, [&](const MTPDgroupCallDiscarded &data) {
|
||||
if (data.vid().v == _id) {
|
||||
_mySsrc = 0;
|
||||
hangup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GroupCall::addParticipantsToInstance() {
|
||||
const auto real = _peer->groupCall();
|
||||
|
@ -849,7 +853,33 @@ void GroupCall::addPreparedParticipantsDelayed() {
|
|||
crl::on_main(this, [=] { addPreparedParticipants(); });
|
||||
}
|
||||
|
||||
void GroupCall::handleUpdate(const MTPUpdate &update) {
|
||||
update.match([&](const MTPDupdateGroupCall &data) {
|
||||
handleUpdate(data);
|
||||
}, [&](const MTPDupdateGroupCallParticipants &data) {
|
||||
handleUpdate(data);
|
||||
}, [](const auto &) {
|
||||
Unexpected("Type in Instance::applyGroupCallUpdateChecked.");
|
||||
});
|
||||
}
|
||||
|
||||
void GroupCall::handleUpdate(const MTPDupdateGroupCall &data) {
|
||||
data.vcall().match([](const MTPDgroupCall &) {
|
||||
}, [&](const MTPDgroupCallDiscarded &data) {
|
||||
if (data.vid().v == _id) {
|
||||
_mySsrc = 0;
|
||||
hangup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GroupCall::handleUpdate(const MTPDupdateGroupCallParticipants &data) {
|
||||
const auto callId = data.vcall().match([](const auto &data) {
|
||||
return data.vid().v;
|
||||
});
|
||||
if (_id != callId) {
|
||||
return;
|
||||
}
|
||||
const auto state = _state.current();
|
||||
if (state != State::Joined && state != State::Connecting) {
|
||||
return;
|
||||
|
|
|
@ -116,8 +116,8 @@ public:
|
|||
void rejoinAs(Group::JoinInfo info);
|
||||
void rejoinWithHash(const QString &hash);
|
||||
void join(const MTPInputGroupCall &inputCall);
|
||||
void handleUpdate(const MTPGroupCall &call);
|
||||
void handleUpdate(const MTPDupdateGroupCallParticipants &data);
|
||||
void handleUpdate(const MTPUpdate &update);
|
||||
void handlePossibleCreateOrJoinResponse(const MTPDupdateGroupCall &data);
|
||||
void changeTitle(const QString &title);
|
||||
void toggleRecording(bool enabled, const QString &title);
|
||||
[[nodiscard]] bool recordingStoppedByMe() const {
|
||||
|
@ -227,6 +227,9 @@ private:
|
|||
RaiseHand,
|
||||
};
|
||||
|
||||
void handlePossibleCreateOrJoinResponse(const MTPDgroupCall &data);
|
||||
void handleUpdate(const MTPDupdateGroupCall &data);
|
||||
void handleUpdate(const MTPDupdateGroupCallParticipants &data);
|
||||
void handleRequestError(const MTP::Error &error);
|
||||
void handleControllerError(const QString &error);
|
||||
void ensureControllerCreated();
|
||||
|
|
|
@ -427,28 +427,23 @@ void Instance::handleGroupCallUpdate(
|
|||
} else {
|
||||
applyGroupCallUpdateChecked(session, update);
|
||||
}
|
||||
|
||||
if (_currentGroupCall
|
||||
&& (&_currentGroupCall->peer()->session() == session)) {
|
||||
update.match([&](const MTPDupdateGroupCall &data) {
|
||||
_currentGroupCall->handlePossibleCreateOrJoinResponse(data);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Instance::applyGroupCallUpdateChecked(
|
||||
not_null<Main::Session*> session,
|
||||
const MTPUpdate &update) {
|
||||
if (!_currentGroupCall
|
||||
|| (&_currentGroupCall->peer()->session() != session)) {
|
||||
return;
|
||||
if (_currentGroupCall
|
||||
&& (&_currentGroupCall->peer()->session() == session)) {
|
||||
_currentGroupCall->handleUpdate(update);
|
||||
}
|
||||
|
||||
update.match([&](const MTPDupdateGroupCall &data) {
|
||||
_currentGroupCall->handleUpdate(data.vcall());
|
||||
}, [&](const MTPDupdateGroupCallParticipants &data) {
|
||||
const auto callId = data.vcall().match([](const auto &data) {
|
||||
return data.vid().v;
|
||||
});
|
||||
if (_currentGroupCall->id() == callId) {
|
||||
_currentGroupCall->handleUpdate(data);
|
||||
}
|
||||
}, [](const auto &) {
|
||||
Unexpected("Type in Instance::applyGroupCallUpdateChecked.");
|
||||
});
|
||||
}
|
||||
|
||||
void Instance::handleSignalingData(
|
||||
|
|
|
@ -137,7 +137,7 @@ private:
|
|||
mtpRequestId _reloadRequestId = 0;
|
||||
rpl::variable<QString> _title;
|
||||
|
||||
base::flat_map<std::pair<int,bool>, MTPUpdate> _queuedUpdates;
|
||||
base::flat_multi_map<std::pair<int,bool>, MTPUpdate> _queuedUpdates;
|
||||
base::Timer _reloadByQueuedUpdatesTimer;
|
||||
|
||||
std::vector<Participant> _participants;
|
||||
|
|
Loading…
Add table
Reference in a new issue