Satisfy rustfmt and clippy on the album and folder picker changes
rustfmt over the files the albums work touched, and the album merge's incoming row as a named struct rather than an eight-field tuple, which clippy's type_complexity refused.
This commit is contained in:
+56
-43
@@ -128,7 +128,11 @@ impl AlbumsController {
|
||||
let borrow = catalog.borrow();
|
||||
let Some(cat) = borrow.as_ref() else { return };
|
||||
if let Err(e) = albums::record_exports(cat.connection(), album, &files) {
|
||||
log::warn!("recording {} exports in album {}: {e}", files.len(), album.0);
|
||||
log::warn!(
|
||||
"recording {} exports in album {}: {e}",
|
||||
files.len(),
|
||||
album.0
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -188,11 +192,12 @@ fn adopt_old_destination(ctl: &AlbumsController, cat: &dr_catalog::Catalog) {
|
||||
return;
|
||||
}
|
||||
let place = Place::Local(export.destination.trim().to_string());
|
||||
match albums::create(conn, "Exports", &place)
|
||||
.and_then(|id| albums::get(conn, id))
|
||||
{
|
||||
match albums::create(conn, "Exports", &place).and_then(|id| albums::get(conn, id)) {
|
||||
Ok(Some(album)) => {
|
||||
log::info!("the export folder {} is now the album “Exports”", export.destination);
|
||||
log::info!(
|
||||
"the export folder {} is now the album “Exports”",
|
||||
export.destination
|
||||
);
|
||||
ctl.settings.edit(|s| s.export.album = album.uuid);
|
||||
}
|
||||
Ok(None) => {}
|
||||
@@ -252,7 +257,10 @@ fn describe(place: Option<&Place>) -> String {
|
||||
fn display_folder(folder: &str) -> String {
|
||||
if folder.starts_with("content://") {
|
||||
let tail = folder.rsplit('/').next().unwrap_or(folder);
|
||||
let decoded = tail.replace("%3A", ":").replace("%2F", "/").replace("%20", " ");
|
||||
let decoded = tail
|
||||
.replace("%3A", ":")
|
||||
.replace("%2F", "/")
|
||||
.replace("%20", " ");
|
||||
return decoded
|
||||
.split_once(':')
|
||||
.map(|(_, p)| p.to_string())
|
||||
@@ -268,7 +276,10 @@ fn render_sheet(window: &AppWindow, ctl: &AlbumsController) {
|
||||
albums.set_sheet_open(false);
|
||||
return;
|
||||
};
|
||||
let server = ctl.library.credentials().is_some_and(|c| !c.account.login.is_empty());
|
||||
let server = ctl
|
||||
.library
|
||||
.credentials()
|
||||
.is_some_and(|c| !c.account.login.is_empty());
|
||||
let refusal = if s.at == Where::Server {
|
||||
refusal(&s.browser.path, ctl)
|
||||
} else {
|
||||
@@ -329,7 +340,9 @@ fn inside(path: &str, root: &str) -> bool {
|
||||
|
||||
/// List the sheet's server folder, and redraw when the answer comes.
|
||||
fn browse(weak: slint::Weak<AppWindow>, ctl: Rc<AlbumsController>, path: String) {
|
||||
let Some(conn) = ctl.library.credentials() else { return };
|
||||
let Some(conn) = ctl.library.credentials() else {
|
||||
return;
|
||||
};
|
||||
if let Some(s) = ctl.sheet.borrow_mut().as_mut() {
|
||||
s.browser.path = path.clone();
|
||||
s.browser.entries.clear();
|
||||
@@ -375,7 +388,10 @@ fn settle(
|
||||
/// Open the sheet — on a new album, or on `editing`.
|
||||
fn open_sheet(window: &AppWindow, ctl: &Rc<AlbumsController>, editing: Option<AlbumId>) {
|
||||
let album = editing.and_then(|id| ctl.rows.borrow().iter().find(|a| a.id == id).cloned());
|
||||
let server = ctl.library.credentials().is_some_and(|c| !c.account.login.is_empty());
|
||||
let server = ctl
|
||||
.library
|
||||
.credentials()
|
||||
.is_some_and(|c| !c.account.login.is_empty());
|
||||
let (at, device_folder, server_path) = match album.as_ref().and_then(|a| a.place.clone()) {
|
||||
Some(Place::Local(f)) => (Where::Device, f, String::new()),
|
||||
Some(Place::Server(p)) => (Where::Server, String::new(), p),
|
||||
@@ -417,14 +433,13 @@ fn save(window: &AppWindow, ctl: &Rc<AlbumsController>) {
|
||||
let Some(cat) = borrow.as_ref() else { return };
|
||||
let conn = cat.connection();
|
||||
match editing {
|
||||
Some(id) => albums::rename(conn, id, &name)
|
||||
.and_then(|()| {
|
||||
let current = albums::get(conn, id)?.and_then(|a| a.place);
|
||||
if current.as_ref() != Some(&place) {
|
||||
albums::set_place(conn, id, &place)?;
|
||||
}
|
||||
Ok(id)
|
||||
}),
|
||||
Some(id) => albums::rename(conn, id, &name).and_then(|()| {
|
||||
let current = albums::get(conn, id)?.and_then(|a| a.place);
|
||||
if current.as_ref() != Some(&place) {
|
||||
albums::set_place(conn, id, &place)?;
|
||||
}
|
||||
Ok(id)
|
||||
}),
|
||||
None => albums::create(conn, &name, &place),
|
||||
}
|
||||
.and_then(|id| Ok((id, albums::get(conn, id)?)))
|
||||
@@ -686,7 +701,9 @@ pub fn wire(
|
||||
let ctl = ctl.clone();
|
||||
albums.on_browse_make(move |name| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let Some(conn) = ctl.library.credentials() else { return };
|
||||
let Some(conn) = ctl.library.credentials() else {
|
||||
return;
|
||||
};
|
||||
let parent = {
|
||||
let mut sheet = ctl.sheet.borrow_mut();
|
||||
let Some(s) = sheet.as_mut() else { return };
|
||||
@@ -700,18 +717,16 @@ pub fn wire(
|
||||
let name = name.trim().to_string();
|
||||
let (weak, ctl2) = (weak.clone(), ctl.clone());
|
||||
let child = name.clone();
|
||||
crate::remote_folders::make(conn, parent.clone(), name, move |result| {
|
||||
match result {
|
||||
Ok(_) => {
|
||||
let path = if parent.is_empty() {
|
||||
child
|
||||
} else {
|
||||
format!("{parent}/{child}")
|
||||
};
|
||||
browse(weak, ctl2, path);
|
||||
}
|
||||
Err(e) => settle(&weak, &ctl2, &parent, Err(e)),
|
||||
crate::remote_folders::make(conn, parent.clone(), name, move |result| match result {
|
||||
Ok(_) => {
|
||||
let path = if parent.is_empty() {
|
||||
child
|
||||
} else {
|
||||
format!("{parent}/{child}")
|
||||
};
|
||||
browse(weak, ctl2, path);
|
||||
}
|
||||
Err(e) => settle(&weak, &ctl2, &parent, Err(e)),
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -720,20 +735,18 @@ pub fn wire(
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = ctl.clone();
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_album_picked(move |i| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let uuid = ctl
|
||||
.rows
|
||||
.borrow()
|
||||
.get(i.max(0) as usize)
|
||||
.map(|a| a.uuid.clone());
|
||||
if let Some(uuid) = uuid {
|
||||
ctl.settings.edit(|s| s.export.album = uuid);
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window.global::<ExportOptions>().on_album_picked(move |i| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let uuid = ctl
|
||||
.rows
|
||||
.borrow()
|
||||
.get(i.max(0) as usize)
|
||||
.map(|a| a.uuid.clone());
|
||||
if let Some(uuid) = uuid {
|
||||
ctl.settings.edit(|s| s.export.album = uuid);
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
|
||||
Reference in New Issue
Block a user