mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Load more story users on demand.
This commit is contained in:
parent
4e165a2107
commit
4a67641460
5 changed files with 30 additions and 1 deletions
|
@ -299,7 +299,9 @@ void Stories::loadMore() {
|
||||||
const auto api = &_owner->session().api();
|
const auto api = &_owner->session().api();
|
||||||
using Flag = MTPstories_GetAllStories::Flag;
|
using Flag = MTPstories_GetAllStories::Flag;
|
||||||
_loadMoreRequestId = api->request(MTPstories_GetAllStories(
|
_loadMoreRequestId = api->request(MTPstories_GetAllStories(
|
||||||
MTP_flags(_state.isEmpty() ? Flag(0) : Flag::f_next),
|
MTP_flags(_state.isEmpty()
|
||||||
|
? Flag(0)
|
||||||
|
: (Flag::f_next | Flag::f_state)),
|
||||||
MTP_string(_state)
|
MTP_string(_state)
|
||||||
)).done([=](const MTPstories_AllStories &result) {
|
)).done([=](const MTPstories_AllStories &result) {
|
||||||
_loadMoreRequestId = 0;
|
_loadMoreRequestId = 0;
|
||||||
|
|
|
@ -342,6 +342,11 @@ InnerWidget::InnerWidget(
|
||||||
_controller->openPeerStories(PeerId(int64(id)));
|
_controller->openPeerStories(PeerId(int64(id)));
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
_stories->loadMoreRequests(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
session().data().stories().loadMore();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
handleChatListEntryRefreshes();
|
handleChatListEntryRefreshes();
|
||||||
|
|
||||||
refreshWithCollapsedRows(true);
|
refreshWithCollapsedRows(true);
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace {
|
||||||
constexpr auto kSmallUserpicsShown = 3;
|
constexpr auto kSmallUserpicsShown = 3;
|
||||||
constexpr auto kSmallReadOpacity = 0.6;
|
constexpr auto kSmallReadOpacity = 0.6;
|
||||||
constexpr auto kSummaryExpandLeft = 1.5;
|
constexpr auto kSummaryExpandLeft = 1.5;
|
||||||
|
constexpr auto kPreloadPages = 2;
|
||||||
|
|
||||||
[[nodiscard]] int AvailableNameWidth() {
|
[[nodiscard]] int AvailableNameWidth() {
|
||||||
const auto &full = st::dialogsStoriesFull;
|
const auto &full = st::dialogsStoriesFull;
|
||||||
|
@ -206,6 +207,7 @@ void List::updateScrollMax() {
|
||||||
const auto widthFull = full.left + int(_data.items.size()) * singleFull;
|
const auto widthFull = full.left + int(_data.items.size()) * singleFull;
|
||||||
_scrollLeftMax = std::max(widthFull - width(), 0);
|
_scrollLeftMax = std::max(widthFull - width(), 0);
|
||||||
_scrollLeft = std::clamp(_scrollLeft, 0, _scrollLeftMax);
|
_scrollLeft = std::clamp(_scrollLeft, 0, _scrollLeftMax);
|
||||||
|
checkLoadMore();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,6 +223,10 @@ rpl::producer<> List::entered() const {
|
||||||
return _entered.events();
|
return _entered.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<> List::loadMoreRequests() const {
|
||||||
|
return _loadMoreRequests.events();
|
||||||
|
}
|
||||||
|
|
||||||
void List::enterEventHook(QEnterEvent *e) {
|
void List::enterEventHook(QEnterEvent *e) {
|
||||||
_entered.fire({});
|
_entered.fire({});
|
||||||
}
|
}
|
||||||
|
@ -597,6 +603,7 @@ void List::wheelEvent(QWheelEvent *e) {
|
||||||
_expandRequests.fire({});
|
_expandRequests.fire({});
|
||||||
_scrollLeft = next;
|
_scrollLeft = next;
|
||||||
updateSelected();
|
updateSelected();
|
||||||
|
checkLoadMore();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
e->accept();
|
e->accept();
|
||||||
|
@ -640,11 +647,18 @@ void List::checkDragging() {
|
||||||
_scrollLeftMax);
|
_scrollLeftMax);
|
||||||
if (newLeft != _scrollLeft) {
|
if (newLeft != _scrollLeft) {
|
||||||
_scrollLeft = newLeft;
|
_scrollLeft = newLeft;
|
||||||
|
checkLoadMore();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void List::checkLoadMore() {
|
||||||
|
if (_scrollLeftMax - _scrollLeft < width() * kPreloadPages) {
|
||||||
|
_loadMoreRequests.fire({});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void List::mouseReleaseEvent(QMouseEvent *e) {
|
void List::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
_lastMousePosition = e->globalPos();
|
_lastMousePosition = e->globalPos();
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
[[nodiscard]] rpl::producer<uint64> clicks() const;
|
[[nodiscard]] rpl::producer<uint64> clicks() const;
|
||||||
[[nodiscard]] rpl::producer<> expandRequests() const;
|
[[nodiscard]] rpl::producer<> expandRequests() const;
|
||||||
[[nodiscard]] rpl::producer<> entered() const;
|
[[nodiscard]] rpl::producer<> entered() const;
|
||||||
|
[[nodiscard]] rpl::producer<> loadMoreRequests() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Layout;
|
struct Layout;
|
||||||
|
@ -110,6 +111,7 @@ private:
|
||||||
void updateSelected();
|
void updateSelected();
|
||||||
void checkDragging();
|
void checkDragging();
|
||||||
bool finishDragging();
|
bool finishDragging();
|
||||||
|
void checkLoadMore();
|
||||||
|
|
||||||
void updateHeight();
|
void updateHeight();
|
||||||
void toggleAnimated(bool shown);
|
void toggleAnimated(bool shown);
|
||||||
|
@ -128,6 +130,7 @@ private:
|
||||||
rpl::event_stream<uint64> _clicks;
|
rpl::event_stream<uint64> _clicks;
|
||||||
rpl::event_stream<> _expandRequests;
|
rpl::event_stream<> _expandRequests;
|
||||||
rpl::event_stream<> _entered;
|
rpl::event_stream<> _entered;
|
||||||
|
rpl::event_stream<> _loadMoreRequests;
|
||||||
|
|
||||||
Ui::Animations::Simple _shownAnimation;
|
Ui::Animations::Simple _shownAnimation;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ constexpr auto kSiblingMultiplierMax = 0.72;
|
||||||
constexpr auto kSiblingOutsidePart = 0.24;
|
constexpr auto kSiblingOutsidePart = 0.24;
|
||||||
constexpr auto kSiblingUserpicSize = 0.3;
|
constexpr auto kSiblingUserpicSize = 0.3;
|
||||||
constexpr auto kInnerHeightMultiplier = 1.6;
|
constexpr auto kInnerHeightMultiplier = 1.6;
|
||||||
|
constexpr auto kPreloadUsersCount = 3;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -381,6 +382,10 @@ void Controller::show(
|
||||||
}
|
}
|
||||||
_index = subindex;
|
_index = subindex;
|
||||||
|
|
||||||
|
if (int(lists.size()) - index < kPreloadUsersCount) {
|
||||||
|
story->peer()->owner().stories().loadMore();
|
||||||
|
}
|
||||||
|
|
||||||
const auto storyId = FullStoryId{
|
const auto storyId = FullStoryId{
|
||||||
.peer = list.user->id,
|
.peer = list.user->id,
|
||||||
.story = id,
|
.story = id,
|
||||||
|
|
Loading…
Add table
Reference in a new issue