mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-05 03:14:28 +00:00
Fix saved music page-after-page loading.
This commit is contained in:
@@ -260,7 +260,8 @@ void SavedMusic::loadMore(PeerId peerId, bool reload) {
|
||||
musicIdToMsg(peerId, entry, document));
|
||||
}
|
||||
}
|
||||
entry.loaded = list.empty() || (count == entry.list.size());
|
||||
entry.loaded = list.empty()
|
||||
|| (entry.total == entry.list.size());
|
||||
});
|
||||
_changed.fire_copy(peerId);
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
@@ -332,24 +333,24 @@ rpl::producer<SavedMusicSlice> SavedMusicList(
|
||||
if (i == end(loaded)) {
|
||||
i = begin(loaded);
|
||||
}
|
||||
const auto hasBefore = int(i - begin(loaded));
|
||||
const auto hasAfter = int(end(loaded) - i);
|
||||
if (hasAfter < limit) {
|
||||
const auto hasAfter = int(i - begin(loaded));
|
||||
const auto hasBefore = int(end(loaded) - i);
|
||||
if (hasBefore < limit) {
|
||||
savedMusic->loadMore(peerId);
|
||||
}
|
||||
const auto takeBefore = std::min(hasBefore, limit);
|
||||
const auto takeAfter = std::min(hasAfter, limit);
|
||||
const auto takeBefore = std::min(hasBefore, limit);
|
||||
auto ids = std::vector<not_null<HistoryItem*>>();
|
||||
ids.reserve(takeBefore + takeAfter);
|
||||
for (auto j = i - takeBefore; j != i + takeAfter; ++j) {
|
||||
ids.reserve(takeAfter + takeBefore);
|
||||
for (auto j = i - takeAfter; j != i + takeBefore; ++j) {
|
||||
ids.push_back(*j);
|
||||
}
|
||||
const auto added = int(ids.size());
|
||||
state->slice = SavedMusicSlice(
|
||||
std::move(ids),
|
||||
count,
|
||||
(hasBefore - takeBefore),
|
||||
count - hasBefore - added);
|
||||
count - (hasAfter - takeAfter) - added,
|
||||
hasAfter - takeAfter);
|
||||
consumer.put_next_copy(state->slice);
|
||||
};
|
||||
const auto schedule = [=] {
|
||||
|
||||
@@ -63,7 +63,7 @@ rpl::producer<StoriesIdsSlice> AlbumStoriesIds(
|
||||
std::move(ids),
|
||||
count,
|
||||
(hasBefore - takeBefore),
|
||||
count - hasBefore - added);
|
||||
count - (hasBefore - takeBefore) - added);
|
||||
consumer.put_next_copy(state->slice);
|
||||
};
|
||||
const auto schedule = [=] {
|
||||
|
||||
@@ -120,7 +120,9 @@ void MusicProvider::checkPreload(
|
||||
const auto visibleWidth = viewport.width();
|
||||
const auto visibleHeight = viewport.height();
|
||||
const auto preloadedHeight = kPreloadedScreensCountFull * visibleHeight;
|
||||
const auto minItemHeight = MinStoryHeight(visibleWidth);
|
||||
const auto minItemHeight = MinItemHeight(
|
||||
Type::MusicFile,
|
||||
visibleWidth);
|
||||
const auto preloadedCount = preloadedHeight / minItemHeight;
|
||||
const auto preloadIdsLimitMin = (preloadedCount / 2) + 1;
|
||||
const auto preloadIdsLimit = preloadIdsLimitMin
|
||||
@@ -165,7 +167,7 @@ void MusicProvider::setSearchQuery(QString query) {
|
||||
void MusicProvider::refreshViewer() {
|
||||
_viewerLifetime.destroy();
|
||||
const auto aroundId = _aroundId;
|
||||
auto ids = Data::SavedMusicList(_peer, aroundId, _idsLimit);
|
||||
auto ids = Data::SavedMusicList(_peer, aroundId, _idsLimit);
|
||||
std::move(
|
||||
ids
|
||||
) | rpl::start_with_next([=](Data::SavedMusicSlice &&slice) {
|
||||
|
||||
Reference in New Issue
Block a user