Split launch_ui::wire into one function per section
The 225-line wire() registered the launch screen's callbacks in nine comment-delimited sections. Lift them into fn's, merging a few adjacent ones that were only a handful of lines each: wire_sign_in covers both the browser flow and the app-password fallback (the same button in two forms), wire_choose_folder_and_open covers opening the folder browser and the final "Open library" press, since both are short and sit back to back. wire_use_folder, wire_sign_out, wire_formats, wire_folder_picker_navigation and wire_copy_url stay as they were sectioned. wire() calls each in the original order and keeps the closing render() call, which every section relies on having run once at startup.
This commit is contained in:
+44
-16
@@ -91,7 +91,19 @@ pub fn wire<F>(window: &AppWindow, controller: Rc<LaunchController>, on_open_lib
|
||||
where
|
||||
F: Fn(Account) + 'static,
|
||||
{
|
||||
// --- sign in -------------------------------------------------------
|
||||
wire_sign_in(window, &controller);
|
||||
wire_use_folder(window, &controller);
|
||||
wire_sign_out(window, &controller);
|
||||
wire_formats(window, &controller);
|
||||
wire_choose_folder_and_open(window, &controller, on_open_library);
|
||||
wire_folder_picker_navigation(window, &controller);
|
||||
wire_copy_url(window, &controller);
|
||||
|
||||
render(window, &controller);
|
||||
}
|
||||
|
||||
/// Sign in: the browser flow, and the app-password fallback.
|
||||
fn wire_sign_in(window: &AppWindow, controller: &Rc<LaunchController>) {
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
@@ -117,7 +129,7 @@ where
|
||||
});
|
||||
}
|
||||
|
||||
// --- sign in with an app password -----------------------------------
|
||||
// Sign in with an app password.
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
@@ -144,13 +156,15 @@ where
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// --- use a folder ---------------------------------------------------
|
||||
//
|
||||
// No thread, no waiting state, no credential: the whole sign-in is a
|
||||
// `stat`. That asymmetry with the browser flow above is not a special
|
||||
// case in the screen — it is what [`SignIn::EndpointOnly`] means, and any
|
||||
// future connector declaring it lands here rather than in new code.
|
||||
/// Use a folder.
|
||||
///
|
||||
/// No thread, no waiting state, no credential: the whole sign-in is a
|
||||
/// `stat`. That asymmetry with the browser flow above is not a special
|
||||
/// case in the screen — it is what [`SignIn::EndpointOnly`] means, and any
|
||||
/// future connector declaring it lands here rather than in new code.
|
||||
fn wire_use_folder(window: &AppWindow, controller: &Rc<LaunchController>) {
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
@@ -166,8 +180,10 @@ where
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// --- sign out ------------------------------------------------------
|
||||
/// Sign out.
|
||||
fn wire_sign_out(window: &AppWindow, controller: &Rc<LaunchController>) {
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
@@ -186,8 +202,10 @@ where
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// --- format tick-boxes ---------------------------------------------
|
||||
/// Format tick-boxes.
|
||||
fn wire_formats(window: &AppWindow, controller: &Rc<LaunchController>) {
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
@@ -210,8 +228,16 @@ where
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// --- choose folder --------------------------------------------------
|
||||
/// Choose folder, and open library.
|
||||
fn wire_choose_folder_and_open<F>(
|
||||
window: &AppWindow,
|
||||
controller: &Rc<LaunchController>,
|
||||
on_open_library: F,
|
||||
) where
|
||||
F: Fn(Account) + 'static,
|
||||
{
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
@@ -223,7 +249,7 @@ where
|
||||
});
|
||||
}
|
||||
|
||||
// --- open library ---------------------------------------------------
|
||||
// Open library.
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
@@ -236,8 +262,10 @@ where
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// --- folder picker navigation ---------------------------------------
|
||||
/// Folder picker navigation.
|
||||
fn wire_folder_picker_navigation(window: &AppWindow, controller: &Rc<LaunchController>) {
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
@@ -296,8 +324,10 @@ where
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// --- copy the login URL ---------------------------------------------
|
||||
/// Copy the login URL.
|
||||
fn wire_copy_url(window: &AppWindow, controller: &Rc<LaunchController>) {
|
||||
{
|
||||
let ctl = controller.clone();
|
||||
window.on_launch_copy_url(move || {
|
||||
@@ -310,8 +340,6 @@ where
|
||||
log::info!("login url: {url}");
|
||||
});
|
||||
}
|
||||
|
||||
render(window, &controller);
|
||||
}
|
||||
|
||||
/// TRACES: FR-NC-13
|
||||
|
||||
Reference in New Issue
Block a user