mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Load more story users on demand.
This commit is contained in:
@@ -19,6 +19,7 @@ namespace {
|
||||
constexpr auto kSmallUserpicsShown = 3;
|
||||
constexpr auto kSmallReadOpacity = 0.6;
|
||||
constexpr auto kSummaryExpandLeft = 1.5;
|
||||
constexpr auto kPreloadPages = 2;
|
||||
|
||||
[[nodiscard]] int AvailableNameWidth() {
|
||||
const auto &full = st::dialogsStoriesFull;
|
||||
@@ -206,6 +207,7 @@ void List::updateScrollMax() {
|
||||
const auto widthFull = full.left + int(_data.items.size()) * singleFull;
|
||||
_scrollLeftMax = std::max(widthFull - width(), 0);
|
||||
_scrollLeft = std::clamp(_scrollLeft, 0, _scrollLeftMax);
|
||||
checkLoadMore();
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -221,6 +223,10 @@ rpl::producer<> List::entered() const {
|
||||
return _entered.events();
|
||||
}
|
||||
|
||||
rpl::producer<> List::loadMoreRequests() const {
|
||||
return _loadMoreRequests.events();
|
||||
}
|
||||
|
||||
void List::enterEventHook(QEnterEvent *e) {
|
||||
_entered.fire({});
|
||||
}
|
||||
@@ -597,6 +603,7 @@ void List::wheelEvent(QWheelEvent *e) {
|
||||
_expandRequests.fire({});
|
||||
_scrollLeft = next;
|
||||
updateSelected();
|
||||
checkLoadMore();
|
||||
update();
|
||||
}
|
||||
e->accept();
|
||||
@@ -640,11 +647,18 @@ void List::checkDragging() {
|
||||
_scrollLeftMax);
|
||||
if (newLeft != _scrollLeft) {
|
||||
_scrollLeft = newLeft;
|
||||
checkLoadMore();
|
||||
update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void List::checkLoadMore() {
|
||||
if (_scrollLeftMax - _scrollLeft < width() * kPreloadPages) {
|
||||
_loadMoreRequests.fire({});
|
||||
}
|
||||
}
|
||||
|
||||
void List::mouseReleaseEvent(QMouseEvent *e) {
|
||||
_lastMousePosition = e->globalPos();
|
||||
const auto guard = gsl::finally([&] {
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
[[nodiscard]] rpl::producer<uint64> clicks() const;
|
||||
[[nodiscard]] rpl::producer<> expandRequests() const;
|
||||
[[nodiscard]] rpl::producer<> entered() const;
|
||||
[[nodiscard]] rpl::producer<> loadMoreRequests() const;
|
||||
|
||||
private:
|
||||
struct Layout;
|
||||
@@ -110,6 +111,7 @@ private:
|
||||
void updateSelected();
|
||||
void checkDragging();
|
||||
bool finishDragging();
|
||||
void checkLoadMore();
|
||||
|
||||
void updateHeight();
|
||||
void toggleAnimated(bool shown);
|
||||
@@ -128,6 +130,7 @@ private:
|
||||
rpl::event_stream<uint64> _clicks;
|
||||
rpl::event_stream<> _expandRequests;
|
||||
rpl::event_stream<> _entered;
|
||||
rpl::event_stream<> _loadMoreRequests;
|
||||
|
||||
Ui::Animations::Simple _shownAnimation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user