Update channel participant count when receiving boost status.
This commit is contained in:
parent
e3bdd30d91
commit
a2c8aa7165
@ -16223,6 +16223,27 @@ void ContactsManager::on_update_channel_stories_hidden(Channel *c, ChannelId cha
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_channel_participant_count(ChannelId channel_id, int32 participant_count) {
|
||||
Channel *c = get_channel(channel_id);
|
||||
if (c == nullptr || c->participant_count == participant_count) {
|
||||
return;
|
||||
}
|
||||
|
||||
c->participant_count = participant_count;
|
||||
c->is_changed = true;
|
||||
update_channel(c, channel_id);
|
||||
|
||||
auto channel_full = get_channel_full(channel_id, true, "on_update_channel_participant_count");
|
||||
if (channel_full != nullptr && channel_full->participant_count != participant_count) {
|
||||
if (channel_full->administrator_count > participant_count) {
|
||||
channel_full->administrator_count = participant_count;
|
||||
}
|
||||
channel_full->participant_count = participant_count;
|
||||
channel_full->is_changed = true;
|
||||
update_channel_full(channel_full, channel_id, "on_update_channel_participant_count");
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_channel_editable_username(ChannelId channel_id, string &&username) {
|
||||
Channel *c = get_channel(channel_id);
|
||||
CHECK(c != nullptr);
|
||||
|
@ -214,6 +214,7 @@ class ContactsManager final : public Actor {
|
||||
void on_update_chat_default_permissions(ChatId chat_id, RestrictedRights default_permissions, int32 version);
|
||||
void on_update_chat_pinned_message(ChatId chat_id, MessageId pinned_message_id, int32 version);
|
||||
|
||||
void on_update_channel_participant_count(ChannelId channel_id, int32 participant_count);
|
||||
void on_update_channel_editable_username(ChannelId channel_id, string &&username);
|
||||
void on_update_channel_usernames(ChannelId channel_id, Usernames &&usernames);
|
||||
void on_update_channel_story_ids(ChannelId channel_id, StoryId max_active_story_id, StoryId max_read_story_id);
|
||||
|
@ -788,11 +788,13 @@ class GetBoostsStatusQuery final : public Td::ResultHandler {
|
||||
int32 premium_member_count = 0;
|
||||
double premium_member_percentage = 0.0;
|
||||
if (result->premium_audience_ != nullptr) {
|
||||
auto part = static_cast<int32>(result->premium_audience_->part_);
|
||||
auto total = static_cast<int32>(result->premium_audience_->total_);
|
||||
premium_member_count = max(0, part);
|
||||
if (result->premium_audience_->total_ > 0) {
|
||||
premium_member_percentage = 100.0 * premium_member_count / max(total, premium_member_count);
|
||||
premium_member_count = max(0, static_cast<int32>(result->premium_audience_->part_));
|
||||
auto participant_count = max(static_cast<int32>(result->premium_audience_->total_), premium_member_count);
|
||||
if (dialog_id_.get_type() == DialogType::Channel) {
|
||||
td_->contacts_manager_->on_update_channel_participant_count(dialog_id_.get_channel_id(), participant_count);
|
||||
}
|
||||
if (participant_count > 0) {
|
||||
premium_member_percentage = 100.0 * premium_member_count / participant_count;
|
||||
}
|
||||
}
|
||||
promise_.set_value(td_api::make_object<td_api::chatBoostStatus>(
|
||||
|
Loading…
Reference in New Issue
Block a user