fix: detect followed playlists correctly in header
Some checks failed
Build for Windows / build-windows (push) Has been cancelled
Some checks failed
Build for Windows / build-windows (push) Has been cancelled
Load owner+subscriber playlists, track all playlist IDs for follow-state resolution, and keep audio ring buffer at 32k as requested.
This commit is contained in:
@@ -128,12 +128,14 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
||||
statusBar()->showMessage(tr("Track added to playlist"), 3000);
|
||||
});
|
||||
connect(m_backend, &QobuzBackend::playlistSubscribed, this, [this](qint64 playlistId) {
|
||||
m_userPlaylistIds.insert(playlistId);
|
||||
m_library->refresh();
|
||||
if (m_content->tracksList()->playlistId() == playlistId)
|
||||
m_content->setCurrentPlaylistFollowed(true);
|
||||
statusBar()->showMessage(tr("Playlist followed"), 3000);
|
||||
});
|
||||
connect(m_backend, &QobuzBackend::playlistUnsubscribed, this, [this](qint64 playlistId) {
|
||||
m_userPlaylistIds.remove(playlistId);
|
||||
m_library->refresh();
|
||||
if (m_content->tracksList()->playlistId() == playlistId)
|
||||
m_content->setCurrentPlaylistFollowed(false);
|
||||
@@ -145,6 +147,10 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
||||
});
|
||||
|
||||
// ---- Library signals ----
|
||||
connect(m_library, &List::Library::userPlaylistIdsChanged,
|
||||
this, [this](const QSet<qint64> &playlistIds) {
|
||||
m_userPlaylistIds = playlistIds;
|
||||
});
|
||||
connect(m_library, &List::Library::userPlaylistsChanged,
|
||||
this, &MainWindow::onUserPlaylistsChanged);
|
||||
connect(m_library, &List::Library::openPlaylistDeleted,
|
||||
@@ -536,12 +542,12 @@ void MainWindow::onPlaylistLoaded(const QJsonObject &playlist)
|
||||
const qint64 myId = AppSettings::instance().userId();
|
||||
const bool isOwned = (myId > 0 && ownerId == myId);
|
||||
|
||||
bool isFollowed = false;
|
||||
for (const auto &pl : m_userPlaylists) {
|
||||
if (pl.first == id) {
|
||||
isFollowed = true;
|
||||
break;
|
||||
}
|
||||
bool isFollowed = isOwned || m_userPlaylistIds.contains(id);
|
||||
if (!isFollowed) {
|
||||
if (playlist.contains("is_subscribed"))
|
||||
isFollowed = playlist["is_subscribed"].toBool();
|
||||
else if (playlist.contains("subscribed_at"))
|
||||
isFollowed = !playlist["subscribed_at"].isNull();
|
||||
}
|
||||
|
||||
m_content->showPlaylist(playlist, isFollowed, isOwned);
|
||||
|
||||
Reference in New Issue
Block a user