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