Separately bought upgrade doesn't auto-add details.

This commit is contained in:
John Preston
2025-09-01 11:23:33 +04:00
parent b075bb9f4e
commit 811dfee42c
6 changed files with 12 additions and 2 deletions
+1
View File
@@ -992,6 +992,7 @@ std::optional<Data::SavedStarGift> FromTL(
? peerFromMTP(*data.vfrom_id())
: PeerId()),
.date = data.vdate().v,
.upgradeSeparate = data.is_upgrade_separate(),
.upgradable = data.is_can_upgrade(),
.anonymous = data.is_name_hidden(),
.pinned = data.is_pinned_to_top() && hasUnique,
+1
View File
@@ -106,6 +106,7 @@ struct CreditsHistoryEntry final {
bool giftTransferred : 1 = false;
bool giftRefunded : 1 = false;
bool giftUpgraded : 1 = false;
bool giftUpgradeSeparate : 1 = false;
bool giftResale : 1 = false;
bool giftResaleForceTon : 1 = false;
bool giftPinned : 1 = false;
@@ -163,6 +163,7 @@ struct GiftCode {
GiftType type = GiftType::Premium;
bool viaGiveaway : 1 = false;
bool transferred : 1 = false;
bool upgradeSeparate : 1 = false;
bool upgradable : 1 = false;
bool unclaimed : 1 = false;
bool anonymous : 1 = false;
@@ -178,6 +178,7 @@ struct SavedStarGift {
QString giftPrepayUpgradeHash;
PeerId fromId = 0;
TimeId date = 0;
bool upgradeSeparate = false;
bool upgradable = false;
bool anonymous = false;
bool pinned = false;
@@ -5869,13 +5869,14 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
const MTPDmessageActionStarGift &action) {
auto result = PreparedServiceText();
const auto upgradeGifted = action.is_prepaid_upgrade();
const auto upgradeSeparate = action.is_upgrade_separate();
const auto isSelf = _from->isSelf();
const auto peer = isSelf ? _history->peer : _from;
const auto stars = action.vgift().match([&](
const MTPDstarGift &data) {
return upgradeGifted
? uint64(action.vupgrade_stars().value_or_empty())
: action.is_upgrade_separate()
: upgradeSeparate
? uint64(data.vstars().v)
: (uint64(data.vstars().v)
+ uint64(action.vupgrade_stars().value_or_empty()));
@@ -6503,6 +6504,7 @@ void HistoryItem::applyAction(const MTPMessageAction &action) {
.starsUpgradedBySender = int(
data.vupgrade_stars().value_or_empty()),
.type = Data::GiftType::StarGift,
.upgradeSeparate = data.is_upgrade_separate(),
.upgradable = data.is_can_upgrade(),
.anonymous = data.is_name_hidden(),
.converted = data.is_converted(),
@@ -1874,7 +1874,9 @@ void GenericCreditsEntryBox(
&& e.hasGiftComment),
.canAddMyComment = (giftToSelf && e.hasGiftComment),
.addDetailsDefault = (giftToSelf
|| (e.starsUpgradedBySender && !e.anonymous)),
|| (e.starsUpgradedBySender
&& !e.giftUpgradeSeparate
&& !e.anonymous)),
});
};
@@ -2553,6 +2555,7 @@ Data::CreditsHistoryEntry SavedStarGiftEntry(
.converted = false,
.anonymous = data.anonymous,
.stargift = true,
.giftUpgradeSeparate = data.upgradeSeparate,
.giftPinned = data.pinned,
.savedToProfile = !data.hidden,
.fromGiftsList = true,
@@ -2657,6 +2660,7 @@ void ShowStarGiftViewBox(
.stargift = true,
.giftTransferred = data.transferred,
.giftRefunded = data.refunded,
.giftUpgradeSeparate = data.upgradeSeparate,
.savedToProfile = data.saved,
.canUpgradeGift = data.upgradable,
.hasGiftComment = !data.message.empty(),