Support new order of group call participants.

This commit is contained in:
levlam 2021-07-09 18:48:10 +03:00
parent 3e351a0946
commit 3682029db2
3 changed files with 16 additions and 12 deletions

View File

@ -80,7 +80,8 @@ GroupCallParticipantOrder GroupCallParticipant::get_real_order(bool can_self_unm
}
auto sort_raise_hand_rating = can_self_unmute ? raise_hand_rating : 0;
auto sort_joined_date = joined_date_asc ? std::numeric_limits<int32>::max() - joined_date : joined_date;
return GroupCallParticipantOrder(sort_active_date, sort_raise_hand_rating, sort_joined_date);
bool has_video = !video_payload.endpoint.empty() || !presentation_payload.endpoint.empty();
return GroupCallParticipantOrder(has_video, sort_active_date, sort_raise_hand_rating, sort_joined_date);
}
bool GroupCallParticipant::get_is_muted_by_themselves() const {

View File

@ -15,11 +15,11 @@
namespace td {
GroupCallParticipantOrder GroupCallParticipantOrder::min() {
return GroupCallParticipantOrder(0, 0, 1);
return GroupCallParticipantOrder(false, 0, 0, 1);
}
GroupCallParticipantOrder GroupCallParticipantOrder::max() {
return GroupCallParticipantOrder(std::numeric_limits<int32>::max(), std::numeric_limits<int64>::max(),
return GroupCallParticipantOrder(true, std::numeric_limits<int32>::max(), std::numeric_limits<int64>::max(),
std::numeric_limits<int32>::max());
}
@ -31,12 +31,12 @@ string GroupCallParticipantOrder::get_group_call_participant_order_object() cons
if (!is_valid()) {
return string();
}
return PSTRING() << lpad0(to_string(active_date), 10) << lpad0(to_string(raise_hand_rating), 19)
<< lpad0(to_string(joined_date), 10);
return PSTRING() << (has_video ? '1' : '0') << lpad0(to_string(active_date), 10)
<< lpad0(to_string(raise_hand_rating), 19) << lpad0(to_string(joined_date), 10);
}
bool operator==(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) {
return lhs.active_date == rhs.active_date && lhs.joined_date == rhs.joined_date &&
return lhs.has_video == rhs.has_video && lhs.active_date == rhs.active_date && lhs.joined_date == rhs.joined_date &&
lhs.raise_hand_rating == rhs.raise_hand_rating;
}
@ -45,8 +45,10 @@ bool operator!=(const GroupCallParticipantOrder &lhs, const GroupCallParticipant
}
bool operator<(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) {
return std::tie(lhs.active_date, lhs.raise_hand_rating, lhs.joined_date) <
std::tie(rhs.active_date, rhs.raise_hand_rating, rhs.joined_date);
auto lhs_has_video = static_cast<int32>(lhs.has_video);
auto rhs_has_video = static_cast<int32>(rhs.has_video);
return std::tie(lhs_has_video, lhs.active_date, lhs.raise_hand_rating, lhs.joined_date) <
std::tie(rhs_has_video, rhs.active_date, rhs.raise_hand_rating, rhs.joined_date);
}
bool operator<=(const GroupCallParticipantOrder &lhs, const GroupCallParticipantOrder &rhs) {
@ -63,8 +65,8 @@ bool operator>=(const GroupCallParticipantOrder &lhs, const GroupCallParticipant
StringBuilder &operator<<(StringBuilder &string_builder,
const GroupCallParticipantOrder &group_call_participant_order) {
return string_builder << group_call_participant_order.active_date << '/'
<< group_call_participant_order.raise_hand_rating << '/'
return string_builder << group_call_participant_order.has_video << '/' << group_call_participant_order.active_date
<< '/' << group_call_participant_order.raise_hand_rating << '/'
<< group_call_participant_order.joined_date;
}

View File

@ -12,6 +12,7 @@
namespace td {
class GroupCallParticipantOrder {
bool has_video = false;
int32 active_date = 0;
int32 joined_date = 0;
int64 raise_hand_rating = 0;
@ -26,8 +27,8 @@ class GroupCallParticipantOrder {
public:
GroupCallParticipantOrder() = default;
GroupCallParticipantOrder(int32 active_date, int64 raise_hand_rating, int32 joined_date)
: active_date(active_date), joined_date(joined_date), raise_hand_rating(raise_hand_rating) {
GroupCallParticipantOrder(bool has_video, int32 active_date, int64 raise_hand_rating, int32 joined_date)
: has_video(has_video), active_date(active_date), joined_date(joined_date), raise_hand_rating(raise_hand_rating) {
}
static GroupCallParticipantOrder min();