mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 06:55:58 +00:00
Fixed request of recent gifts only when peer has gifts.
This commit is contained in:
@@ -316,10 +316,10 @@ not_null<Ui::SettingsButton*> AddPeerGiftsButton(
|
|||||||
});
|
});
|
||||||
|
|
||||||
struct State final {
|
struct State final {
|
||||||
std::optional<MTP::Sender> api;
|
|
||||||
std::vector<std::unique_ptr<Ui::Text::CustomEmoji>> emojiList;
|
std::vector<std::unique_ptr<Ui::Text::CustomEmoji>> emojiList;
|
||||||
rpl::event_stream<> textRefreshed;
|
rpl::event_stream<> textRefreshed;
|
||||||
QPointer<Ui::SettingsButton> button;
|
QPointer<Ui::SettingsButton> button;
|
||||||
|
rpl::lifetime appearedLifetime;
|
||||||
};
|
};
|
||||||
const auto state = parent->lifetime().make_state<State>();
|
const auto state = parent->lifetime().make_state<State>();
|
||||||
|
|
||||||
@@ -329,8 +329,6 @@ not_null<Ui::SettingsButton*> AddPeerGiftsButton(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
state->api.emplace(&navigation->session().mtp());
|
|
||||||
|
|
||||||
auto customs = state->textRefreshed.events(
|
auto customs = state->textRefreshed.events(
|
||||||
) | rpl::map([=]() -> TextWithEntities {
|
) | rpl::map([=]() -> TextWithEntities {
|
||||||
auto result = TextWithEntities();
|
auto result = TextWithEntities();
|
||||||
@@ -365,16 +363,21 @@ not_null<Ui::SettingsButton*> AddPeerGiftsButton(
|
|||||||
wrap->toggleOn(rpl::duplicate(forked) | rpl::map(rpl::mappers::_1 > 0));
|
wrap->toggleOn(rpl::duplicate(forked) | rpl::map(rpl::mappers::_1 > 0));
|
||||||
tracker.track(wrap);
|
tracker.track(wrap);
|
||||||
|
|
||||||
const auto requestDone = crl::guard(wrap, [=](
|
rpl::duplicate(forked) | rpl::filter(
|
||||||
std::vector<DocumentId> ids) {
|
rpl::mappers::_1 > 0
|
||||||
state->emojiList.clear();
|
) | rpl::start_with_next([=] {
|
||||||
for (const auto &id : ids) {
|
state->appearedLifetime.destroy();
|
||||||
state->emojiList.push_back(
|
const auto requestDone = crl::guard(wrap, [=](
|
||||||
peer->owner().customEmojiManager().create(id, refresh));
|
std::vector<DocumentId> ids) {
|
||||||
}
|
state->emojiList.clear();
|
||||||
state->textRefreshed.fire({});
|
for (const auto &id : ids) {
|
||||||
});
|
state->emojiList.push_back(
|
||||||
navigation->session().recentSharedGifts().request(peer, requestDone);
|
peer->owner().customEmojiManager().create(id, refresh));
|
||||||
|
}
|
||||||
|
state->textRefreshed.fire({});
|
||||||
|
});
|
||||||
|
navigation->session().recentSharedGifts().request(peer, requestDone);
|
||||||
|
}, state->appearedLifetime);
|
||||||
|
|
||||||
state->button = wrap->entity();
|
state->button = wrap->entity();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user