diff --git a/Telegram/SourceFiles/api/api_premium.cpp b/Telegram/SourceFiles/api/api_premium.cpp index b05355d24b..069eb05dbe 100644 --- a/Telegram/SourceFiles/api/api_premium.cpp +++ b/Telegram/SourceFiles/api/api_premium.cpp @@ -911,6 +911,7 @@ std::optional FromTL( .starsForResale = FindStarsForResale(data.vresell_amount()), .number = data.vnum().v, .onlyAcceptTon = data.is_resale_ton_only(), + .canBeTheme = data.is_theme_available(), .model = *model, .pattern = *pattern, .value = (data.vvalue_amount() diff --git a/Telegram/SourceFiles/data/data_star_gift.h b/Telegram/SourceFiles/data/data_star_gift.h index 86dc5b132a..d78cf6c2a3 100644 --- a/Telegram/SourceFiles/data/data_star_gift.h +++ b/Telegram/SourceFiles/data/data_star_gift.h @@ -67,6 +67,7 @@ struct UniqueGift { int starsForTransfer = -1; int number = 0; bool onlyAcceptTon = false; + bool canBeTheme = false; TimeId exportAt = 0; TimeId canTransferAt = 0; TimeId canResellAt = 0; diff --git a/Telegram/SourceFiles/ui/chat/chat_theme.cpp b/Telegram/SourceFiles/ui/chat/chat_theme.cpp index 6dd873f6cb..d5deb53f6a 100644 --- a/Telegram/SourceFiles/ui/chat/chat_theme.cpp +++ b/Telegram/SourceFiles/ui/chat/chat_theme.cpp @@ -535,7 +535,8 @@ bool ChatTheme::readyForBackgroundRotation() const { } void ChatTheme::generateNextBackgroundRotation() { - if (_backgroundCachingRequest + if (_nextCachingRequest + || _backgroundCachingRequest || !_backgroundNext.image.isNull() || !readyForBackgroundRotation() || background().colors.size() < 3) { @@ -548,8 +549,9 @@ void ChatTheme::generateNextBackgroundRotation() { if (!request) { return; } + _nextCachingRequest = request; cacheBackgroundAsync(request, [=](CacheBackgroundResult &&result) { - const auto forRequest = base::take(_backgroundCachingRequest); + const auto forRequest = base::take(_nextCachingRequest); if (!readyForBackgroundRotation()) { return; } @@ -601,7 +603,9 @@ void ChatTheme::cacheBackgroundNow() { void ChatTheme::cacheBackgroundAsync( const CacheBackgroundRequest &request, Fn done) { - _backgroundCachingRequest = request; + if (!done) { + _backgroundCachingRequest = request; + } const auto weak = base::make_weak(this); crl::async([=] { if (!weak) { diff --git a/Telegram/SourceFiles/ui/chat/chat_theme.h b/Telegram/SourceFiles/ui/chat/chat_theme.h index 10b76f4c16..9c1643dfbb 100644 --- a/Telegram/SourceFiles/ui/chat/chat_theme.h +++ b/Telegram/SourceFiles/ui/chat/chat_theme.h @@ -202,7 +202,9 @@ private: BackgroundState _backgroundState; Animations::Simple _backgroundFade; CacheBackgroundRequest _backgroundCachingRequest; + CacheBackgroundRequest _nextCachingRequest; CacheBackgroundResult _backgroundNext; + int _backgroundVersion = 0; QSize _cacheBackgroundArea; crl::time _lastBackgroundAreaChangeTime = 0; std::optional _cacheBackgroundTimer;