mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Add special toast title for anonymous stars.
This commit is contained in:
parent
4701badb2a
commit
65d6636a41
5 changed files with 43 additions and 14 deletions
|
@ -3806,6 +3806,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_paid_react_agree_link" = "Terms of Service";
|
||||
"lng_paid_react_toast#one" = "Star Sent!";
|
||||
"lng_paid_react_toast#other" = "Stars Sent!";
|
||||
"lng_paid_react_toast_anonymous#one" = "Star sent anonymously!";
|
||||
"lng_paid_react_toast_anonymous#other" = "Stars sent anonymously!";
|
||||
"lng_paid_react_toast_text#one" = "You reacted with **{count} Star**.";
|
||||
"lng_paid_react_toast_text#other" = "You reacted with **{count} Stars**.";
|
||||
"lng_paid_react_undo" = "Undo";
|
||||
|
|
|
@ -2694,6 +2694,10 @@ int HistoryItem::reactionsPaidScheduled() const {
|
|||
return _reactions ? _reactions->scheduledPaid() : 0;
|
||||
}
|
||||
|
||||
bool HistoryItem::reactionsLocalAnonymous() const {
|
||||
return _reactions ? _reactions->localPaidAnonymous() : false;
|
||||
}
|
||||
|
||||
bool HistoryItem::reactionsAreTags() const {
|
||||
return _flags & MessageFlag::ReactionsAreTags;
|
||||
}
|
||||
|
@ -5337,19 +5341,28 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
|||
&_history->session(),
|
||||
amount,
|
||||
currency);
|
||||
result.links.push_back(peer->createOpenLink());
|
||||
result.text = isSelf
|
||||
? tr::lng_action_gift_sent(tr::now,
|
||||
lt_cost,
|
||||
cost,
|
||||
Ui::Text::WithEntities)
|
||||
: tr::lng_action_gift_received(
|
||||
const auto anonymous = _from->isServiceUser();
|
||||
if (anonymous) {
|
||||
result.text = tr::lng_action_gift_received_anonymous(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Link(peer->shortName(), 1), // Link 1.
|
||||
lt_cost,
|
||||
cost,
|
||||
Ui::Text::WithEntities);
|
||||
} else {
|
||||
result.links.push_back(peer->createOpenLink());
|
||||
result.text = isSelf
|
||||
? tr::lng_action_gift_sent(tr::now,
|
||||
lt_cost,
|
||||
cost,
|
||||
Ui::Text::WithEntities)
|
||||
: tr::lng_action_gift_received(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Link(peer->shortName(), 1), // Link 1.
|
||||
lt_cost,
|
||||
cost,
|
||||
Ui::Text::WithEntities);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
|
|
@ -471,6 +471,7 @@ public:
|
|||
[[nodiscard]] auto topPaidReactionsWithLocal() const
|
||||
-> std::vector<Data::MessageReactionsTopPaid>;
|
||||
[[nodiscard]] int reactionsPaidScheduled() const;
|
||||
[[nodiscard]] bool reactionsLocalAnonymous() const;
|
||||
[[nodiscard]] bool canViewReactions() const;
|
||||
[[nodiscard]] std::vector<Data::ReactionId> chosenReactions() const;
|
||||
[[nodiscard]] Data::ReactionId lookupUnreadReaction(
|
||||
|
|
|
@ -163,6 +163,7 @@ PaidReactionToast::~PaidReactionToast() {
|
|||
|
||||
bool PaidReactionToast::maybeShowFor(not_null<HistoryItem*> item) {
|
||||
const auto count = item->reactionsPaidScheduled();
|
||||
const auto anonymous = item->reactionsLocalAnonymous();
|
||||
const auto at = _owner->reactions().sendingScheduledPaidAt(item);
|
||||
if (!count || !at) {
|
||||
return false;
|
||||
|
@ -172,13 +173,14 @@ bool PaidReactionToast::maybeShowFor(not_null<HistoryItem*> item) {
|
|||
if (at <= crl::now() + ignore) {
|
||||
return false;
|
||||
}
|
||||
showFor(item->fullId(), count, at - ignore, total);
|
||||
showFor(item->fullId(), count, anonymous, at - ignore, total);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PaidReactionToast::showFor(
|
||||
FullMsgId itemId,
|
||||
int count,
|
||||
bool anonymous,
|
||||
crl::time finish,
|
||||
crl::time total) {
|
||||
const auto old = _weak.get();
|
||||
|
@ -186,6 +188,7 @@ void PaidReactionToast::showFor(
|
|||
if (i != end(_stack)) {
|
||||
if (old && i + 1 == end(_stack)) {
|
||||
_count = count;
|
||||
_anonymous = anonymous;
|
||||
_timeFinish = finish;
|
||||
return;
|
||||
}
|
||||
|
@ -199,14 +202,22 @@ void PaidReactionToast::showFor(
|
|||
_hiding.push_back(base::take(_weak));
|
||||
}
|
||||
_count.reset();
|
||||
_anonymous.reset();
|
||||
_timeFinish.reset();
|
||||
_count = count;
|
||||
_anonymous = anonymous;
|
||||
_timeFinish = finish;
|
||||
auto text = rpl::combine(
|
||||
tr::lng_paid_react_toast(
|
||||
lt_count,
|
||||
_count.value() | tr::to_count(),
|
||||
Ui::Text::Bold),
|
||||
rpl::conditional(
|
||||
_anonymous.value(),
|
||||
tr::lng_paid_react_toast_anonymous(
|
||||
lt_count,
|
||||
_count.value() | tr::to_count(),
|
||||
Ui::Text::Bold),
|
||||
tr::lng_paid_react_toast(
|
||||
lt_count,
|
||||
_count.value() | tr::to_count(),
|
||||
Ui::Text::Bold)),
|
||||
tr::lng_paid_react_toast_text(
|
||||
lt_count_decimal,
|
||||
_count.value() | tr::to_count(),
|
||||
|
|
|
@ -40,6 +40,7 @@ private:
|
|||
void showFor(
|
||||
FullMsgId itemId,
|
||||
int count,
|
||||
bool anonymous,
|
||||
crl::time left,
|
||||
crl::time total);
|
||||
|
||||
|
@ -53,6 +54,7 @@ private:
|
|||
base::weak_ptr<Ui::Toast::Instance> _weak;
|
||||
std::vector<base::weak_ptr<Ui::Toast::Instance>> _hiding;
|
||||
rpl::variable<int> _count;
|
||||
rpl::variable<bool> _anonymous;
|
||||
rpl::variable<crl::time> _timeFinish;
|
||||
|
||||
std::vector<FullMsgId> _stack;
|
||||
|
|
Loading…
Add table
Reference in a new issue