| 814 | } |
| 815 | |
| 816 | rpl::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 | |
| 836 | std::optional<Data::StarGift> FromTL( |
| 837 | not_null<Main::Session*> session, |
no test coverage detected