2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Correctly show premium promo for custom reactions.

This commit is contained in:
John Preston
2022-08-30 10:53:07 +04:00
parent a3c110dafa
commit ebf6cea2f5
8 changed files with 75 additions and 47 deletions

View File

@@ -184,18 +184,21 @@ Reactions::Reactions(not_null<Session*> owner)
_repaintItems.remove(item);
}, _lifetime);
rpl::single(rpl::empty) | rpl::then(
_owner->session().mtp().config().updates()
) | rpl::map([=] {
const auto &config = _owner->session().mtp().configValues();
return config.reactionDefaultCustom
? ReactionId{ DocumentId(config.reactionDefaultCustom) }
: ReactionId{ config.reactionDefaultEmoji };
}) | rpl::filter([=](const ReactionId &id) {
return !_saveFaveRequestId;
}) | rpl::start_with_next([=](ReactionId &&id) {
applyFavorite(id);
}, _lifetime);
crl::on_main(&owner->session(), [=] {
// applyFavorite accesses not yet constructed parts of session.
rpl::single(rpl::empty) | rpl::then(
_owner->session().mtp().config().updates()
) | rpl::map([=] {
const auto &config = _owner->session().mtp().configValues();
return config.reactionDefaultCustom
? ReactionId{ DocumentId(config.reactionDefaultCustom) }
: ReactionId{ config.reactionDefaultEmoji };
}) | rpl::filter([=](const ReactionId &id) {
return !_saveFaveRequestId;
}) | rpl::start_with_next([=](ReactionId &&id) {
applyFavorite(id);
}, _lifetime);
});
}
Reactions::~Reactions() = default;