mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Queue skipped self updates in voice chats.
This commit is contained in:
parent
0e47c6b415
commit
d41bd1483e
2 changed files with 90 additions and 71 deletions
|
@ -548,6 +548,7 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
|
||||||
applyMeInCallLocally();
|
applyMeInCallLocally();
|
||||||
maybeSendMutedUpdate(wasMuteState);
|
maybeSendMutedUpdate(wasMuteState);
|
||||||
_peer->session().api().applyUpdates(updates);
|
_peer->session().api().applyUpdates(updates);
|
||||||
|
applyQueuedSelfUpdates();
|
||||||
checkFirstTimeJoined();
|
checkFirstTimeJoined();
|
||||||
}).fail([=](const MTP::Error &error) {
|
}).fail([=](const MTP::Error &error) {
|
||||||
const auto type = error.type();
|
const auto type = error.type();
|
||||||
|
@ -991,41 +992,39 @@ void GroupCall::handleUpdate(const MTPDupdateGroupCallParticipants &data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto state = _state.current();
|
const auto state = _state.current();
|
||||||
if (state != State::Joined && state != State::Connecting) {
|
const auto joined = (state == State::Joined)
|
||||||
return;
|
|| (state == State::Connecting);
|
||||||
}
|
|
||||||
|
|
||||||
const auto handleOtherParticipants = [=](
|
|
||||||
const MTPDgroupCallParticipant &data) {
|
|
||||||
if (data.is_min()) {
|
|
||||||
// No real information about mutedByMe or my custom volume.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto participantPeer = _peer->owner().peer(
|
|
||||||
peerFromMTP(data.vpeer()));
|
|
||||||
const auto participant = LookupParticipant(
|
|
||||||
_peer,
|
|
||||||
_id,
|
|
||||||
participantPeer);
|
|
||||||
if (!participant) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_otherParticipantStateValue.fire(Group::ParticipantState{
|
|
||||||
.peer = participantPeer,
|
|
||||||
.volume = data.vvolume().value_or_empty(),
|
|
||||||
.mutedByMe = data.is_muted_by_you(),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const auto &participant : data.vparticipants().v) {
|
for (const auto &participant : data.vparticipants().v) {
|
||||||
participant.match([&](const MTPDgroupCallParticipant &data) {
|
participant.match([&](const MTPDgroupCallParticipant &data) {
|
||||||
const auto isSelf = data.is_self()
|
const auto isSelf = data.is_self()
|
||||||
|| (data.is_min()
|
|| (data.is_min()
|
||||||
&& peerFromMTP(data.vpeer()) == _joinAs->id);
|
&& peerFromMTP(data.vpeer()) == _joinAs->id);
|
||||||
if (!isSelf) {
|
if (!isSelf) {
|
||||||
handleOtherParticipants(data);
|
applyOtherParticipantUpdate(data);
|
||||||
return;
|
} else if (joined) {
|
||||||
|
applySelfUpdate(data);
|
||||||
|
} else {
|
||||||
|
_queuedSelfUpdates.push_back(participant);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GroupCall::applyQueuedSelfUpdates() {
|
||||||
|
const auto weak = base::make_weak(this);
|
||||||
|
while (weak
|
||||||
|
&& !_queuedSelfUpdates.empty()
|
||||||
|
&& (_state.current() == State::Joined
|
||||||
|
|| _state.current() == State::Connecting)) {
|
||||||
|
const auto update = _queuedSelfUpdates.front();
|
||||||
|
_queuedSelfUpdates.erase(_queuedSelfUpdates.begin());
|
||||||
|
update.match([&](const MTPDgroupCallParticipant &data) {
|
||||||
|
applySelfUpdate(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GroupCall::applySelfUpdate(const MTPDgroupCallParticipant &data) {
|
||||||
if (data.is_left()) {
|
if (data.is_left()) {
|
||||||
if (data.vsource().v == _mySsrc) {
|
if (data.vsource().v == _mySsrc) {
|
||||||
// I was removed from the call, rejoin.
|
// I was removed from the call, rejoin.
|
||||||
|
@ -1069,8 +1068,24 @@ void GroupCall::handleUpdate(const MTPDupdateGroupCallParticipants &data) {
|
||||||
} else if (data.is_muted() && muted() != MuteState::Muted) {
|
} else if (data.is_muted() && muted() != MuteState::Muted) {
|
||||||
setMuted(MuteState::Muted);
|
setMuted(MuteState::Muted);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
void GroupCall::applyOtherParticipantUpdate(
|
||||||
|
const MTPDgroupCallParticipant &data) {
|
||||||
|
if (data.is_min()) {
|
||||||
|
// No real information about mutedByMe or my custom volume.
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
const auto participantPeer = _peer->owner().peer(
|
||||||
|
peerFromMTP(data.vpeer()));
|
||||||
|
if (!LookupParticipant(_peer, _id, participantPeer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_otherParticipantStateValue.fire(Group::ParticipantState{
|
||||||
|
.peer = participantPeer,
|
||||||
|
.volume = data.vvolume().value_or_empty(),
|
||||||
|
.mutedByMe = data.is_muted_by_you(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::changeTitle(const QString &title) {
|
void GroupCall::changeTitle(const QString &title) {
|
||||||
|
|
|
@ -290,6 +290,9 @@ private:
|
||||||
not_null<PeerData*> participantPeer,
|
not_null<PeerData*> participantPeer,
|
||||||
bool mute,
|
bool mute,
|
||||||
std::optional<int> volume);
|
std::optional<int> volume);
|
||||||
|
void applyQueuedSelfUpdates();
|
||||||
|
void applySelfUpdate(const MTPDgroupCallParticipant &data);
|
||||||
|
void applyOtherParticipantUpdate(const MTPDgroupCallParticipant &data);
|
||||||
|
|
||||||
[[nodiscard]] MTPInputGroupCall inputCall() const;
|
[[nodiscard]] MTPInputGroupCall inputCall() const;
|
||||||
|
|
||||||
|
@ -321,6 +324,7 @@ private:
|
||||||
bool _acceptFields = false;
|
bool _acceptFields = false;
|
||||||
|
|
||||||
rpl::event_stream<Group::ParticipantState> _otherParticipantStateValue;
|
rpl::event_stream<Group::ParticipantState> _otherParticipantStateValue;
|
||||||
|
std::vector<MTPGroupCallParticipant> _queuedSelfUpdates;
|
||||||
|
|
||||||
uint64 _id = 0;
|
uint64 _id = 0;
|
||||||
uint64 _accessHash = 0;
|
uint64 _accessHash = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue