mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +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
Telegram/SourceFiles
|
@ -299,7 +299,9 @@ void Stories::loadMore() {
|
|||
const auto api = &_owner->session().api();
|
||||
using Flag = MTPstories_GetAllStories::Flag;
|
||||
_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)
|
||||
)).done([=](const MTPstories_AllStories &result) {
|
||||
_loadMoreRequestId = 0;
|
||||
|
|
|
@ -342,6 +342,11 @@ InnerWidget::InnerWidget(
|
|||
_controller->openPeerStories(PeerId(int64(id)));
|
||||
}, lifetime());
|
||||
|
||||
_stories->loadMoreRequests(
|
||||
) | rpl::start_with_next([=] {
|
||||
session().data().stories().loadMore();
|
||||
}, lifetime());
|
||||
|
||||
handleChatListEntryRefreshes();
|
||||
|
||||
refreshWithCollapsedRows(true);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ constexpr auto kSiblingMultiplierMax = 0.72;
|
|||
constexpr auto kSiblingOutsidePart = 0.24;
|
||||
constexpr auto kSiblingUserpicSize = 0.3;
|
||||
constexpr auto kInnerHeightMultiplier = 1.6;
|
||||
constexpr auto kPreloadUsersCount = 3;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -381,6 +382,10 @@ void Controller::show(
|
|||
}
|
||||
_index = subindex;
|
||||
|
||||
if (int(lists.size()) - index < kPreloadUsersCount) {
|
||||
story->peer()->owner().stories().loadMore();
|
||||
}
|
||||
|
||||
const auto storyId = FullStoryId{
|
||||
.peer = list.user->id,
|
||||
.story = id,
|
||||
|
|
Loading…
Add table
Reference in a new issue