Update send gift icon visibility.

This commit is contained in:
John Preston 2025-03-21 18:34:26 +04:00
parent 8b2a549fab
commit 44d9525476
2 changed files with 15 additions and 1 deletions

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_global_privacy.h"
#include "apiwrap.h"
#include "data/data_user.h"
#include "main/main_session.h"
#include "main/main_app_config.h"
@ -263,6 +264,8 @@ void GlobalPrivacy::update(
| ((disallowedGiftTypes & DisallowedGiftType::Unique)
? DisallowedFlag::f_disallow_unique_stargifts
: DisallowedFlag());
const auto typesWas = _disallowedGiftTypes.current();
const auto typesChanged = (typesWas != disallowedGiftTypes);
_requestId = _api.request(MTPaccount_SetGlobalPrivacySettings(
MTP_globalPrivacySettings(
MTP_flags(flags),
@ -271,6 +274,9 @@ void GlobalPrivacy::update(
)).done([=](const MTPGlobalPrivacySettings &result) {
_requestId = 0;
apply(result);
if (typesChanged) {
_session->user()->updateFullForced();
}
}).fail([=](const MTP::Error &error) {
_requestId = 0;
if (error.type() == u"PREMIUM_ACCOUNT_REQUIRED"_q) {

View file

@ -814,7 +814,15 @@ HistoryWidget::HistoryWidget(
| PeerUpdateFlag::StarsPerMessage
| PeerUpdateFlag::GiftSettings
) | rpl::filter([=](const Data::PeerUpdate &update) {
return (update.peer.get() == _peer);
if (update.peer.get() == _peer) {
return true;
} else if (update.peer->isSelf()
&& (update.flags & PeerUpdateFlag::GiftSettings)) {
refreshSendGiftToggle();
updateControlsVisibility();
updateControlsGeometry();
}
return false;
}) | rpl::map([](const Data::PeerUpdate &update) {
return update.flags;
}) | rpl::start_with_next([=](Data::PeerUpdate::Flags flags) {