mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Always show "View" button in gifts.
This commit is contained in:
parent
6844f88567
commit
a23dca080a
5 changed files with 33 additions and 39 deletions
|
@ -1205,7 +1205,7 @@ void AddStarGiftTable(
|
|||
const auto unique = entry.uniqueGift.get();
|
||||
const auto selfBareId = session->userPeerId().value;
|
||||
const auto giftToSelf = (peerId == session->userPeerId())
|
||||
&& (!entry.fromGiftsList || entry.bareGiftOwnerId == selfBareId);
|
||||
&& (entry.in || entry.bareGiftOwnerId == selfBareId);
|
||||
if (unique) {
|
||||
const auto ownerId = PeerId(entry.bareGiftOwnerId);
|
||||
const auto transfer = entry.in
|
||||
|
|
|
@ -185,7 +185,7 @@ TextWithEntities PremiumGift::subtitle() {
|
|||
|
||||
rpl::producer<QString> PremiumGift::button() {
|
||||
return (starGift() && outgoingGift())
|
||||
? nullptr
|
||||
? tr::lng_sticker_premium_view()
|
||||
: creditsPrize()
|
||||
? tr::lng_view_button_giftcode()
|
||||
: (starGift() && _data.starsUpgradedBySender && !_data.upgraded)
|
||||
|
@ -200,9 +200,6 @@ bool PremiumGift::buttonMinistars() {
|
|||
}
|
||||
|
||||
ClickHandlerPtr PremiumGift::createViewLink() {
|
||||
if (starGift() && outgoingGift()) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto from = _gift->from();
|
||||
const auto itemId = _parent->data()->fullId();
|
||||
const auto peer = _parent->history()->peer;
|
||||
|
|
|
@ -440,8 +440,6 @@ auto GenerateUniqueGiftMedia(
|
|||
gift->backdrop.textColor,
|
||||
st::chatUniqueTextPadding);
|
||||
|
||||
const auto withButton = !outgoing || item->history()->peer->isSelf();
|
||||
|
||||
auto attributes = std::vector<AttributeTable::Entry>{
|
||||
{ tr::lng_gift_unique_model(tr::now), gift->model.name },
|
||||
{ tr::lng_gift_unique_backdrop(tr::now), gift->backdrop.name },
|
||||
|
@ -449,38 +447,34 @@ auto GenerateUniqueGiftMedia(
|
|||
};
|
||||
push(std::make_unique<AttributeTable>(
|
||||
std::move(attributes),
|
||||
(withButton
|
||||
? st::chatUniqueTextPadding
|
||||
: st::chatUniqueTableAtBottomPadding),
|
||||
st::chatUniqueTextPadding,
|
||||
gift->backdrop.textColor));
|
||||
|
||||
if (withButton) {
|
||||
const auto itemId = parent->data()->fullId();
|
||||
auto link = std::make_shared<LambdaClickHandler>([=](
|
||||
ClickContext context) {
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
if (const auto controller = my.sessionWindow.get()) {
|
||||
const auto owner = &controller->session().data();
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto gift = media->gift()) {
|
||||
controller->show(Box(
|
||||
Settings::StarGiftViewBox,
|
||||
controller,
|
||||
*gift,
|
||||
item));
|
||||
}
|
||||
const auto itemId = parent->data()->fullId();
|
||||
auto link = std::make_shared<LambdaClickHandler>([=](
|
||||
ClickContext context) {
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
if (const auto controller = my.sessionWindow.get()) {
|
||||
const auto owner = &controller->session().data();
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto gift = media->gift()) {
|
||||
controller->show(Box(
|
||||
Settings::StarGiftViewBox,
|
||||
controller,
|
||||
*gift,
|
||||
item));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
push(std::make_unique<ButtonPart>(
|
||||
tr::lng_sticker_premium_view(tr::now),
|
||||
st::chatUniqueButtonPadding,
|
||||
[=] { parent->repaint(); },
|
||||
std::move(link),
|
||||
anim::with_alpha(gift->backdrop.patternColor, 0.75)));
|
||||
}
|
||||
}
|
||||
});
|
||||
push(std::make_unique<ButtonPart>(
|
||||
tr::lng_sticker_premium_view(tr::now),
|
||||
st::chatUniqueButtonPadding,
|
||||
[=] { parent->repaint(); },
|
||||
std::move(link),
|
||||
anim::with_alpha(gift->backdrop.patternColor, 0.75)));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1008,7 +1008,7 @@ void ReceiptCreditsBox(
|
|||
const auto selfPeerId = session->userPeerId().value;
|
||||
const auto giftToSelf = isStarGift
|
||||
&& (e.barePeerId == selfPeerId)
|
||||
&& (!e.fromGiftsList || e.bareGiftOwnerId == selfPeerId);
|
||||
&& (e.in || e.bareGiftOwnerId == selfPeerId);
|
||||
|
||||
if (!uniqueGift) {
|
||||
Ui::AddSkip(content);
|
||||
|
@ -1684,17 +1684,21 @@ void StarGiftViewBox(
|
|||
not_null<Window::SessionController*> controller,
|
||||
const Data::GiftCode &data,
|
||||
not_null<HistoryItem*> item) {
|
||||
const auto incoming = data.upgrade ? item->out() : !item->out();
|
||||
const auto peer = item->history()->peer;
|
||||
const auto fromId = incoming ? peer->id : peer->session().userPeerId();
|
||||
const auto toId = incoming ? peer->session().userPeerId() : peer->id;
|
||||
const auto entry = Data::CreditsHistoryEntry{
|
||||
.id = data.slug,
|
||||
.description = data.message,
|
||||
.date = base::unixtime::parse(item->date()),
|
||||
.credits = StarsAmount(data.count),
|
||||
.bareMsgId = uint64(item->id.bare),
|
||||
.barePeerId = item->history()->peer->id.value,
|
||||
.barePeerId = fromId.value,
|
||||
.bareGiftStickerId = data.document ? data.document->id : 0,
|
||||
.bareGiftOwnerId = (data.unique
|
||||
? data.unique->ownerId.value
|
||||
: item->history()->session().userPeerId().value),
|
||||
: toId.value),
|
||||
.stargiftId = data.stargiftId,
|
||||
.uniqueGift = data.unique,
|
||||
.peerType = Data::CreditsHistoryEntry::PeerType::Peer,
|
||||
|
@ -1711,7 +1715,7 @@ void StarGiftViewBox(
|
|||
.savedToProfile = data.saved,
|
||||
.canUpgradeGift = data.upgradable,
|
||||
.hasGiftComment = !data.message.empty(),
|
||||
.in = true,
|
||||
.in = incoming,
|
||||
.gift = true,
|
||||
};
|
||||
Settings::ReceiptCreditsBox(
|
||||
|
|
|
@ -1217,6 +1217,5 @@ chatUniqueTitle: TextStyle(defaultTextStyle) {
|
|||
chatUniqueTitlePadding: margins(12px, 12px, 12px, 2px);
|
||||
chatUniqueTextPadding: margins(12px, 2px, 12px, 8px);
|
||||
chatUniqueTableSkip: 9px;
|
||||
chatUniqueTableAtBottomPadding: margins(12px, 2px, 12px, 20px);
|
||||
chatUniqueRowSkip: 4px;
|
||||
chatUniqueButtonPadding: margins(12px, 4px, 12px, 16px);
|
||||
|
|
Loading…
Add table
Reference in a new issue