mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-15 02:02:52 +02:00
Fixed request of recent gifts only when peer has gifts.
This commit is contained in:
parent
f2f5ffd861
commit
20815eecbc
1 changed files with 16 additions and 13 deletions
|
@ -316,10 +316,10 @@ not_null<Ui::SettingsButton*> AddPeerGiftsButton(
|
|||
});
|
||||
|
||||
struct State final {
|
||||
std::optional<MTP::Sender> api;
|
||||
std::vector<std::unique_ptr<Ui::Text::CustomEmoji>> emojiList;
|
||||
rpl::event_stream<> textRefreshed;
|
||||
QPointer<Ui::SettingsButton> button;
|
||||
rpl::lifetime appearedLifetime;
|
||||
};
|
||||
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(
|
||||
) | rpl::map([=]() -> TextWithEntities {
|
||||
auto result = TextWithEntities();
|
||||
|
@ -365,16 +363,21 @@ not_null<Ui::SettingsButton*> AddPeerGiftsButton(
|
|||
wrap->toggleOn(rpl::duplicate(forked) | rpl::map(rpl::mappers::_1 > 0));
|
||||
tracker.track(wrap);
|
||||
|
||||
const auto requestDone = crl::guard(wrap, [=](
|
||||
std::vector<DocumentId> ids) {
|
||||
state->emojiList.clear();
|
||||
for (const auto &id : ids) {
|
||||
state->emojiList.push_back(
|
||||
peer->owner().customEmojiManager().create(id, refresh));
|
||||
}
|
||||
state->textRefreshed.fire({});
|
||||
});
|
||||
navigation->session().recentSharedGifts().request(peer, requestDone);
|
||||
rpl::duplicate(forked) | rpl::filter(
|
||||
rpl::mappers::_1 > 0
|
||||
) | rpl::start_with_next([=] {
|
||||
state->appearedLifetime.destroy();
|
||||
const auto requestDone = crl::guard(wrap, [=](
|
||||
std::vector<DocumentId> ids) {
|
||||
state->emojiList.clear();
|
||||
for (const auto &id : ids) {
|
||||
state->emojiList.push_back(
|
||||
peer->owner().customEmojiManager().create(id, refresh));
|
||||
}
|
||||
state->textRefreshed.fire({});
|
||||
});
|
||||
navigation->session().recentSharedGifts().request(peer, requestDone);
|
||||
}, state->appearedLifetime);
|
||||
|
||||
state->button = wrap->entity();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue