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