Skip to content

Commit a2ab6c6

Browse files
committed
Update gift count only if full list of gifts was requested.
1 parent 1fc859d commit a2ab6c6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

td/telegram/StarGiftManager.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,7 @@ class GetSavedStarGiftsQuery final : public Td::ResultHandler {
11811181
Promise<td_api::object_ptr<td_api::receivedGifts>> promise_;
11821182
DialogId dialog_id_;
11831183
BusinessConnectionId business_connection_id_;
1184+
bool is_full_list_ = false;
11841185

11851186
public:
11861187
explicit GetSavedStarGiftsQuery(Promise<td_api::object_ptr<td_api::receivedGifts>> &&promise)
@@ -1196,6 +1197,9 @@ class GetSavedStarGiftsQuery final : public Td::ResultHandler {
11961197
business_connection_id.is_valid()
11971198
? DialogId(td_->business_connection_manager_->get_business_connection_user_id(business_connection_id))
11981199
: dialog_id;
1200+
is_full_list_ = !collection_id.is_valid() && !exclude_unsaved && !exclude_saved && !exclude_unlimited &&
1201+
!exclude_upgradable && !exclude_non_upgradable && !exclude_unique && !peer_color_available &&
1202+
!exclude_hosted;
11991203
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Read);
12001204
if (input_peer == nullptr) {
12011205
return on_error(Status::Error(400, "Can't access the chat"));
@@ -1241,12 +1245,16 @@ class GetSavedStarGiftsQuery final : public Td::ResultHandler {
12411245
bool are_notifications_enabled = false;
12421246
if (dialog_id_.get_type() == DialogType::User) {
12431247
if (dialog_id_ != td_->dialog_manager_->get_my_dialog_id()) {
1244-
td_->user_manager_->on_update_user_gift_count(dialog_id_.get_user_id(), total_count);
1248+
if (is_full_list_) {
1249+
td_->user_manager_->on_update_user_gift_count(dialog_id_.get_user_id(), total_count);
1250+
}
12451251
} else {
12461252
are_notifications_enabled = true;
12471253
}
12481254
} else if (dialog_id_.get_type() == DialogType::Channel) {
1249-
td_->chat_manager_->on_update_channel_gift_count(dialog_id_.get_channel_id(), total_count, false);
1255+
if (is_full_list_) {
1256+
td_->chat_manager_->on_update_channel_gift_count(dialog_id_.get_channel_id(), total_count, false);
1257+
}
12501258
are_notifications_enabled = ptr->chat_notifications_enabled_;
12511259
}
12521260
promise_.set_value(td_api::make_object<td_api::receivedGifts>(total_count, std::move(gifts),

0 commit comments

Comments
 (0)