Skip to content

Commit 1dc70d5

Browse files
committed
Load gift themes while scrolling.
1 parent e876a0f commit 1dc70d5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Telegram/SourceFiles/ui/chat/choose_theme_controller.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ void ChooseThemeController::updateInnerLeft(int now) {
560560
? (skip / 2)
561561
: std::clamp(now, skip, 0);
562562
_inner->move(clamped, 0);
563+
const auto visibleTill = -clamped + _content->width();
564+
if (_giftsFinishAt - visibleTill < _content->width()) {
565+
_peer->owner().cloudThemes().myGiftThemesLoadMore();
566+
}
563567
}
564568

565569
void ChooseThemeController::close() {
@@ -734,13 +738,15 @@ void ChooseThemeController::fill(
734738
x += single.width() + skip;
735739
};
736740

741+
_giftsFinishAt = 0;
737742
if (const auto now = cloudThemes->themeForToken(initial)) {
738743
push(*now, initial);
739744
}
740745
for (const auto &token : cloudThemes->myGiftThemesTokens()) {
741746
if (const auto found = cloudThemes->themeForToken(token)) {
742747
if (token != initial) {
743748
push(*found, token);
749+
_giftsFinishAt = x;
744750
}
745751
}
746752
}

Telegram/SourceFiles/ui/chat/choose_theme_controller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class ChooseThemeController final {
7373
std::optional<QPoint> _pressPosition;
7474
std::optional<QPoint> _dragStartPosition;
7575
int _dragStartInnerLeft = 0;
76+
int _giftsFinishAt = 0;
7677
bool _initialInnerLeftApplied = false;
7778

7879
rpl::variable<bool> _shouldBeShown = false;

0 commit comments

Comments
 (0)