mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Use correct phrases for outgoing giftcodes.
This commit is contained in:
parent
fddbce5dce
commit
de8b09d7fc
5 changed files with 68 additions and 26 deletions
Telegram/SourceFiles
boxes
history
settings
|
@ -720,7 +720,7 @@ void AddTable(
|
|||
controller,
|
||||
current.from);
|
||||
}
|
||||
if (current.to) {
|
||||
if (current.from && current.to) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_gift_link_label_to(),
|
||||
|
@ -739,7 +739,7 @@ void AddTable(
|
|||
lt_duration,
|
||||
GiftDurationValue(current.months) | Ui::Text::ToWithEntities(),
|
||||
Ui::Text::WithEntities));
|
||||
if (!skipReason) {
|
||||
if (!skipReason && current.from) {
|
||||
const auto reason = AddTableRow(
|
||||
table,
|
||||
tr::lng_gift_link_label_reason(),
|
||||
|
@ -1178,13 +1178,19 @@ void ResolveGiftCode(
|
|||
PeerId fromId,
|
||||
PeerId toId) {
|
||||
const auto done = [=](Api::GiftCode code) {
|
||||
const auto session = &controller->session();
|
||||
const auto selfId = session->userPeerId();
|
||||
if (!code) {
|
||||
controller->showToast(tr::lng_gift_link_expired(tr::now));
|
||||
} else if (!code.from && fromId == selfId) {
|
||||
code.from = fromId;
|
||||
code.to = toId;
|
||||
const auto self = (fromId == selfId);
|
||||
const auto peer = session->data().peer(self ? toId : fromId);
|
||||
const auto months = code.months;
|
||||
const auto parent = controller->parentController();
|
||||
Settings::ShowGiftPremium(parent, peer, months, self);
|
||||
} else {
|
||||
if (!code.from) {
|
||||
code.from = fromId;
|
||||
code.to = toId;
|
||||
}
|
||||
controller->uiShow()->showBox(Box(GiftCodeBox, controller, slug));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4530,19 +4530,35 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
|||
auto prepareGiftCode = [&](const MTPDmessageActionGiftCode &action) {
|
||||
auto result = PreparedServiceText();
|
||||
_history->session().giftBoxStickersPacks().load();
|
||||
result.text = {
|
||||
(action.is_unclaimed()
|
||||
? tr::lng_prize_unclaimed_about
|
||||
: action.is_via_giveaway()
|
||||
? tr::lng_prize_about
|
||||
: tr::lng_prize_gift_about)(
|
||||
if (const auto boosted = action.vboost_peer()) {
|
||||
result.text = {
|
||||
(action.is_unclaimed()
|
||||
? tr::lng_prize_unclaimed_about
|
||||
: action.is_via_giveaway()
|
||||
? tr::lng_prize_about
|
||||
: tr::lng_prize_gift_about)(
|
||||
tr::now,
|
||||
lt_channel,
|
||||
_from->owner().peer(
|
||||
peerFromMTP(*action.vboost_peer()))->name()),
|
||||
};
|
||||
} else {
|
||||
const auto isSelf = (_from->id == _from->session().userPeerId());
|
||||
const auto peer = isSelf ? _history->peer : _from;
|
||||
result.links.push_back(peer->createOpenLink());
|
||||
result.text = (isSelf
|
||||
? tr::lng_action_gift_received_me
|
||||
: tr::lng_action_gift_received)(
|
||||
tr::now,
|
||||
lt_channel,
|
||||
(action.vboost_peer()
|
||||
? _from->owner().peer(
|
||||
peerFromMTP(*action.vboost_peer()))->name()
|
||||
: "a channel")),
|
||||
};
|
||||
lt_user,
|
||||
Ui::Text::Link(peer->name(), 1), // Link 1.
|
||||
lt_cost,
|
||||
{ Ui::FillAmountAndCurrency(
|
||||
action.vamount().value_or_empty(),
|
||||
qs(action.vcurrency().value_or_empty())) },
|
||||
Ui::Text::WithEntities);
|
||||
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
@ -4697,7 +4713,7 @@ void HistoryItem::applyAction(const MTPMessageAction &action) {
|
|||
_from,
|
||||
Data::GiftCode{
|
||||
.slug = qs(data.vslug()),
|
||||
.channel = (peerIsChannel(boostedId)
|
||||
.channel = (boostedId
|
||||
? history()->owner().channel(boostedId).get()
|
||||
: nullptr),
|
||||
.months = data.vmonths().v,
|
||||
|
|
|
@ -43,7 +43,7 @@ QSize PremiumGift::size() {
|
|||
}
|
||||
|
||||
QString PremiumGift::title() {
|
||||
return _data.slug.isEmpty()
|
||||
return gift()
|
||||
? tr::lng_premium_summary_title(tr::now)
|
||||
: _data.unclaimed
|
||||
? tr::lng_prize_unclaimed_title(tr::now)
|
||||
|
@ -51,7 +51,7 @@ QString PremiumGift::title() {
|
|||
}
|
||||
|
||||
TextWithEntities PremiumGift::subtitle() {
|
||||
if (_data.slug.isEmpty()) {
|
||||
if (gift()) {
|
||||
return { GiftDuration(_data.months) };
|
||||
}
|
||||
const auto name = _data.channel ? _data.channel->name() : "channel";
|
||||
|
@ -78,7 +78,7 @@ TextWithEntities PremiumGift::subtitle() {
|
|||
}
|
||||
|
||||
rpl::producer<QString> PremiumGift::button() {
|
||||
return _data.slug.isEmpty()
|
||||
return (gift() && (outgoingGift() || !_data.unclaimed))
|
||||
? tr::lng_sticker_premium_view()
|
||||
: tr::lng_prize_open();
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ void PremiumGift::draw(
|
|||
}
|
||||
|
||||
bool PremiumGift::hideServiceText() {
|
||||
return !_data.slug.isEmpty();
|
||||
return !gift();
|
||||
}
|
||||
|
||||
void PremiumGift::stickerClearLoopPlayed() {
|
||||
|
@ -148,6 +148,18 @@ void PremiumGift::unloadHeavyPart() {
|
|||
}
|
||||
}
|
||||
|
||||
bool PremiumGift::incomingGift() const {
|
||||
return gift() && !_parent->data()->out();
|
||||
}
|
||||
|
||||
bool PremiumGift::outgoingGift() const {
|
||||
return gift() && _parent->data()->out();
|
||||
}
|
||||
|
||||
bool PremiumGift::gift() const {
|
||||
return _data.slug.isEmpty() || !_data.channel;
|
||||
}
|
||||
|
||||
void PremiumGift::ensureStickerCreated() const {
|
||||
if (_sticker) {
|
||||
return;
|
||||
|
|
|
@ -46,6 +46,9 @@ public:
|
|||
void unloadHeavyPart() override;
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool incomingGift() const;
|
||||
[[nodiscard]] bool outgoingGift() const;
|
||||
[[nodiscard]] bool gift() const;
|
||||
void ensureStickerCreated() const;
|
||||
|
||||
const not_null<Element*> _parent;
|
||||
|
|
|
@ -871,6 +871,7 @@ void Premium::setStepDataReference(std::any &data) {
|
|||
void Premium::setupSubscriptionOptions(
|
||||
not_null<Ui::VerticalLayout*> container) {
|
||||
const auto isEmojiStatus = (!!Ref::EmojiStatus::Parse(_ref));
|
||||
const auto isGift = (!!Ref::Gift::Parse(_ref));
|
||||
|
||||
const auto options = container->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
|
@ -900,15 +901,19 @@ void Premium::setupSubscriptionOptions(
|
|||
Ui::AddSkip(content, lastSkip - st::defaultVerticalListSkip);
|
||||
Ui::AddSkip(skip->entity(), lastSkip);
|
||||
|
||||
if (isEmojiStatus || isGift) {
|
||||
options->toggle(false, anim::type::instant);
|
||||
skip->toggle(true, anim::type::instant);
|
||||
return;
|
||||
}
|
||||
auto toggleOn = rpl::combine(
|
||||
Data::AmPremiumValue(&_controller->session()),
|
||||
rpl::single(isEmojiStatus),
|
||||
apiPremium->statusTextValue(
|
||||
) | rpl::map([=] {
|
||||
return apiPremium->subscriptionOptions().size() < 2;
|
||||
})
|
||||
) | rpl::map([=](bool premium, bool isEmojiStatus, bool noOptions) {
|
||||
return !premium && !isEmojiStatus && !noOptions;
|
||||
) | rpl::map([=](bool premium, bool noOptions) {
|
||||
return !premium && !noOptions;
|
||||
});
|
||||
options->toggleOn(rpl::duplicate(toggleOn), anim::type::instant);
|
||||
skip->toggleOn(std::move(
|
||||
|
|
Loading…
Add table
Reference in a new issue