fix(qbz-qt): clear a detail view's document when the next one opens

Opening album B after album A showed A's contents until B's fetch landed. The
open path raised the loading flag but left the previous document in place, so
the view had stale data to render and dutifully rendered it — and the wait grew
when the album fetch gained the Last.fm row.

Album, artist, playlist and the local album view now clear in the SAME hop that
raises the flag. That is the half of loading state the port was missing: a
placeholder over stale content is worse than one over nothing, because the user
cannot tell it is stale.

cc
This commit is contained in:
vicrodh committed 2026-07-28 17:40:50 -06:00
1 parent 83999fc552
commit 2b31d3866c
2 files changed
+21 -3

No files matched your search

+6 -1
View File
@@ -494,7 +494,12 @@ impl qbz_local::QbzLocal {
pub fn open_album(self: Pin<&mut Self>, id: QString) {
let id = id.to_string();
ui(|mut b| b.as_mut().set_local_album_loading(true));
ui(|mut b| {
// Clear the previous local album with the loading flag — the same
// stale-render the catalog album view had.
b.as_mut().set_local_album_json(QString::from(""));
b.as_mut().set_local_album_loading(true);
});
crate::spawn(async move {
let detail = tokio::task::spawn_blocking(move || lib::load_album_detail_blocking(&id))
.await
+15 -2
View File
@@ -425,7 +425,13 @@ pub(crate) fn open_album(album_id: String) {
nav_qt::record("album");
*LAST_DETAIL.lock().unwrap() = ("album".to_string(), album_id.clone());
let runtime = app();
album_bridge::ui(move |mut b| b.as_mut().set_album_loading(true));
album_bridge::ui(move |mut b| {
// Clear the PREVIOUS album in the same hop that raises the loading
// flag: without it the view renders the last album until the fetch
// lands, so opening B after A showed A.
b.as_mut().set_album_json(QString::from("{}"));
b.as_mut().set_album_loading(true);
});
spawn(async move {
match album_qt::load_album_view(&runtime, &album_id).await {
Ok(json) => {
@@ -450,7 +456,11 @@ pub(crate) fn open_artist(artist_id: String) {
nav_qt::record("artist");
*LAST_DETAIL.lock().unwrap() = ("artist".to_string(), artist_id.clone());
let runtime = app();
artist_bridge::ui(move |mut b| b.as_mut().set_artist_loading(true));
artist_bridge::ui(move |mut b| {
// Same as open_album: stale artist until the fetch lands otherwise.
b.as_mut().set_artist_json(QString::from("{}"));
b.as_mut().set_artist_loading(true);
});
spawn(async move {
match artist_qt::load_artist_view(&runtime, &artist_id).await {
Ok(json) => artist_bridge::ui(move |mut b| {
@@ -689,6 +699,9 @@ pub(crate) fn open_playlist(playlist_id: String) {
return;
};
nav_qt::record("playlist");
// Clear the previous playlist before the fetch — same stale-render as the
// album and artist views had.
ui(|mut b| b.as_mut().set_playlist_json(QString::from("{}")));
let runtime = app();
spawn(async move {
if let Err(e) = playlist_qt::load(&runtime, pid).await {