diff --git a/Telegram/SourceFiles/data/data_saved_music.cpp b/Telegram/SourceFiles/data/data_saved_music.cpp index 0d0e9d325e..04f2f937af 100644 --- a/Telegram/SourceFiles/data/data_saved_music.cpp +++ b/Telegram/SourceFiles/data/data_saved_music.cpp @@ -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 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>(); - 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 = [=] { diff --git a/Telegram/SourceFiles/data/data_stories_ids.cpp b/Telegram/SourceFiles/data/data_stories_ids.cpp index 130cb5e327..04b36e148e 100644 --- a/Telegram/SourceFiles/data/data_stories_ids.cpp +++ b/Telegram/SourceFiles/data/data_stories_ids.cpp @@ -63,7 +63,7 @@ rpl::producer AlbumStoriesIds( std::move(ids), count, (hasBefore - takeBefore), - count - hasBefore - added); + count - (hasBefore - takeBefore) - added); consumer.put_next_copy(state->slice); }; const auto schedule = [=] { diff --git a/Telegram/SourceFiles/info/saved/info_saved_music_provider.cpp b/Telegram/SourceFiles/info/saved/info_saved_music_provider.cpp index 605a58e3a7..04f152fb6c 100644 --- a/Telegram/SourceFiles/info/saved/info_saved_music_provider.cpp +++ b/Telegram/SourceFiles/info/saved/info_saved_music_provider.cpp @@ -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) {