fix(reco): route Recommendations MusicBrainz lookups through the core client
recommendations_qt and external_reco_qt built private MusicBrainzClient instances, which start enabled and ignore the musicbrainz_enabled opt-out that integrations_qt applies to the core's client. Expose the core's Arc<MusicBrainzClient> and borrow it instead, so a disabled MusicBrainz sends zero requests from Discover > Recommendations. The tag editor's three private clients stay: those are explicit manual lookups the user triggers by hand. cc
This commit is contained in:
3 files changed
+18
-6
No files matched your search
@@ -2243,6 +2243,14 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
|
||||
self.musicbrainz.set_enabled(enabled).await;
|
||||
}
|
||||
|
||||
/// The core's shared MusicBrainz client — the ONE instance whose enabled
|
||||
/// flag `musicbrainz_set_enabled` toggles. Frontend code that needs a
|
||||
/// client must borrow this one: a private `MusicBrainzClient::new()`
|
||||
/// starts enabled and silently ignores the user's opt-out.
|
||||
pub fn musicbrainz_client(&self) -> Arc<MusicBrainzClient> {
|
||||
Arc::clone(&self.musicbrainz)
|
||||
}
|
||||
|
||||
/// Resolve an artist name to a MusicBrainz id. Returns `None` if no
|
||||
/// confident match is found.
|
||||
pub async fn musicbrainz_resolve_artist(
|
||||
|
||||
@@ -23,7 +23,6 @@ use qbz_external_reco::{
|
||||
RecoInputs,
|
||||
};
|
||||
use qbz_integrations::lastfm::LastFmClient;
|
||||
use qbz_integrations::musicbrainz::MusicBrainzClient;
|
||||
use qbz_models::{Album, Artist, Track};
|
||||
|
||||
/// Same 30-day TTL as the Slint side.
|
||||
@@ -150,7 +149,9 @@ pub async fn similar_albums(
|
||||
}
|
||||
|
||||
let lastfm_client = LastFmClient::new();
|
||||
let mb_client = MusicBrainzClient::new();
|
||||
// The core's client (respects the MusicBrainz opt-out) — see the same
|
||||
// note in `recommendations_qt::run`.
|
||||
let mb_client = runtime.core().musicbrainz_client();
|
||||
let catalog = CoreRecoCatalog {
|
||||
runtime: runtime.clone(),
|
||||
};
|
||||
@@ -160,7 +161,7 @@ pub async fn similar_albums(
|
||||
client: &lastfm_client,
|
||||
}),
|
||||
listenbrainz: None,
|
||||
musicbrainz: &mb_client,
|
||||
musicbrainz: mb_client.as_ref(),
|
||||
catalog: &catalog,
|
||||
cache: cache.as_ref(),
|
||||
local: LocalHistory::default(),
|
||||
|
||||
@@ -62,7 +62,6 @@ use qbz_external_reco::{
|
||||
};
|
||||
use qbz_integrations::lastfm::LastFmClient;
|
||||
use qbz_integrations::listenbrainz::ListenBrainzClient;
|
||||
use qbz_integrations::musicbrainz::MusicBrainzClient;
|
||||
use qbz_models::Artist;
|
||||
|
||||
use crate::home_qt::{HomeCard, HomeSection};
|
||||
@@ -669,7 +668,11 @@ async fn run(force: bool) {
|
||||
)
|
||||
.await;
|
||||
}
|
||||
let mb_client = MusicBrainzClient::new();
|
||||
// The core's client, not a private one: only the core instance carries
|
||||
// the `musicbrainz_enabled` opt-out (integrations_qt::start applies it),
|
||||
// and a disabled client answers every lookup with an error the builders
|
||||
// already treat as "no MusicBrainz" — zero requests leave the machine.
|
||||
let mb_client = crate::app().core().musicbrainz_client();
|
||||
|
||||
// CONNECTED, not merely enabled: a `None` handle is what makes the row
|
||||
// absent AND silent (the builders early-return before any request).
|
||||
@@ -717,7 +720,7 @@ async fn run(force: bool) {
|
||||
let inputs = RecoInputs {
|
||||
lastfm,
|
||||
listenbrainz,
|
||||
musicbrainz: &mb_client,
|
||||
musicbrainz: mb_client.as_ref(),
|
||||
catalog: &catalog,
|
||||
cache: cache.as_ref(),
|
||||
local: LocalHistory {
|
||||
|
||||
Reference in new issue
Block a user