From e6d89d6cab933500da954d3d914ff6fe417efd2d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 17:56:09 -0800 Subject: [PATCH] Cloud: send no folder listing while a sign-in waits for its answer browse and load_shared checked only that a service was wired. A call made after sign_in and before the account answer sent a listing in the new session. When its answer arrived after the account answer, the folder kept it and read as loaded, although the listing could be the previous account's. Both now return while the sign-in is outstanding, as save_as does; start already waits on the folders' loading state. --- crates/cloud-ui/src/cloud/mod.rs | 11 ++++++++--- crates/cloud-ui/src/cloud/tests.rs | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/crates/cloud-ui/src/cloud/mod.rs b/crates/cloud-ui/src/cloud/mod.rs index 22ad808595..fb3f0a5541 100644 --- a/crates/cloud-ui/src/cloud/mod.rs +++ b/crates/cloud-ui/src/cloud/mod.rs @@ -419,17 +419,22 @@ pub fn sign_out(app: &mut A) { } /// Lists one folder. An empty path is the user's root. +/// +/// Nothing is sent while a sign-in waits for its answer. A listing sent then +/// can answer after the account does, and its files may be the previous +/// account's; the answer empties the folder so it is listed again. pub fn browse(app: &mut A, path: &str) { - if !available(app) { + if !available(app) || app.cloud().relist_after_sign_in { return; } app.cloud_mut().mine.begin(path); submit(app, Job::List(path.to_owned())); } -/// Lists what other people have shared with this user. +/// Lists what other people have shared with this user. Like [`browse`], it +/// sends nothing while a sign-in waits for its answer. pub fn load_shared(app: &mut A) { - if !available(app) { + if !available(app) || app.cloud().relist_after_sign_in { return; } app.cloud_mut().shared.begin(""); diff --git a/crates/cloud-ui/src/cloud/tests.rs b/crates/cloud-ui/src/cloud/tests.rs index e4f85654ca..82f818db01 100644 --- a/crates/cloud-ui/src/cloud/tests.rs +++ b/crates/cloud-ui/src/cloud/tests.rs @@ -479,6 +479,31 @@ fn a_sign_in_that_drops_a_listing_leaves_no_folder_loading() { assert_eq!(report(&app)["entries"], serde_json::json!(["Minutes.note", "Archive"])); } +#[test] +fn a_listing_asked_for_before_the_sign_in_answers_is_not_sent() { + let (mut app, jobs, ctx) = wired(); + sign_in(&mut app); + jobs.lock().unwrap().clear(); + + // Asked for after the sign-in and before its answer. A listing sent now + // could answer after the account does, and its files may be the previous + // account's. + browse(&mut app, ""); + load_shared(&mut app); + assert!( + !jobs.lock().unwrap().iter().any(|j| matches!(j, Job::List(_) | Job::SharedWithMe)), + "no listing goes out while the sign-in is outstanding" + ); + pumped(&mut app, &ctx); + assert!(!app.cloud.mine.loaded && !app.cloud.mine.loading, "the folder waits to be listed for the new account"); + assert!(!app.cloud.shared.loaded && !app.cloud.shared.loading, "and so does the shared one"); + + // Once the sign-in has answered, a listing goes through. + browse(&mut app, ""); + pumped(&mut app, &ctx); + assert!(app.cloud.mine.loaded); +} + #[test] fn bytes_are_said_the_way_a_person_reads_them() { assert_eq!(size_text(None), "");