MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / RandomHelloStickerValue

Function RandomHelloStickerValue

Telegram/SourceFiles/api/api_premium.cpp:816–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

814}
815
816rpl::producer<DocumentData*> RandomHelloStickerValue(
817 not_null<Main::Session*> session) {
818 const auto premium = &session->api().premium();
819 const auto random = [=] {
820 const auto &v = premium->helloStickers();
821 Assert(!v.empty());
822 return v[base::RandomIndex(v.size())].get();
823 };
824 const auto &v = premium->helloStickers();
825 if (!v.empty()) {
826 return rpl::single(random());
827 }
828 return rpl::single<DocumentData*>(
829 nullptr
830 ) | rpl::then(premium->helloStickersUpdated(
831 ) | rpl::filter([=] {
832 return !premium->helloStickers().empty();
833 }) | rpl::take(1) | rpl::map(random));
834}
835
836std::optional<Data::StarGift> FromTL(
837 not_null<Main::Session*> session,

Callers 1

IntroWithRandomStickerFunction · 0.85

Calls 7

apiMethod · 0.80
helloStickersMethod · 0.80
helloStickersUpdatedMethod · 0.80
premiumMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected