Fix pattern caching on themed chat open.

This commit is contained in:
John Preston
2025-08-28 17:53:56 +04:00
parent d51944e6a5
commit b868cfdca9
4 changed files with 11 additions and 3 deletions

View File

@@ -911,6 +911,7 @@ std::optional<Data::StarGift> 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()

View File

@@ -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;

View File

@@ -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<void(CacheBackgroundResult&&)> done) {
_backgroundCachingRequest = request;
if (!done) {
_backgroundCachingRequest = request;
}
const auto weak = base::make_weak(this);
crl::async([=] {
if (!weak) {

View File

@@ -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<base::Timer> _cacheBackgroundTimer;