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:
+57
-39
@@ -91,7 +91,11 @@ fn text(env: &mut jni::Env, value: JObject) -> jni::errors::Result<Option<String
|
||||
/// activity, and this one's event loop keeps running under it.
|
||||
pub fn pick_tree(chosen: impl FnOnce(String) + 'static) {
|
||||
let started = call("opening the folder picker", |env, activity| {
|
||||
let cls = class(env, activity, jni::jni_str!("paris.tourolle.darkroom.FolderPicker"))?;
|
||||
let cls = class(
|
||||
env,
|
||||
activity,
|
||||
jni::jni_str!("paris.tourolle.darkroom.FolderPicker"),
|
||||
)?;
|
||||
env.call_static_method(
|
||||
&cls,
|
||||
jni::jni_str!("start"),
|
||||
@@ -112,44 +116,52 @@ pub fn pick_tree(chosen: impl FnOnce(String) + 'static) {
|
||||
let mut chosen = Some(chosen);
|
||||
let since = Instant::now();
|
||||
let timer = slint::Timer::default();
|
||||
timer.start(slint::TimerMode::Repeated, Duration::from_millis(250), move || {
|
||||
let answer = call("reading the folder picker", |env, activity| {
|
||||
let cls = class(env, activity, jni::jni_str!("paris.tourolle.darkroom.FolderPicker"))?;
|
||||
let value = env
|
||||
.call_static_method(
|
||||
&cls,
|
||||
jni::jni_str!("poll"),
|
||||
jni::jni_sig!("()Ljava/lang/String;"),
|
||||
&[],
|
||||
)?
|
||||
.l()?;
|
||||
text(env, value)
|
||||
});
|
||||
let finished = match answer {
|
||||
Ok(None) => since.elapsed() > Duration::from_secs(600),
|
||||
Ok(Some(uri)) => {
|
||||
if !uri.is_empty() {
|
||||
if let Some(chosen) = chosen.take() {
|
||||
chosen(uri);
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("{e}");
|
||||
true
|
||||
}
|
||||
};
|
||||
if finished {
|
||||
if let Some(t) = held.borrow().as_ref() {
|
||||
t.stop();
|
||||
}
|
||||
let held = held.clone();
|
||||
slint::Timer::single_shot(Duration::ZERO, move || {
|
||||
held.borrow_mut().take();
|
||||
timer.start(
|
||||
slint::TimerMode::Repeated,
|
||||
Duration::from_millis(250),
|
||||
move || {
|
||||
let answer = call("reading the folder picker", |env, activity| {
|
||||
let cls = class(
|
||||
env,
|
||||
activity,
|
||||
jni::jni_str!("paris.tourolle.darkroom.FolderPicker"),
|
||||
)?;
|
||||
let value = env
|
||||
.call_static_method(
|
||||
&cls,
|
||||
jni::jni_str!("poll"),
|
||||
jni::jni_sig!("()Ljava/lang/String;"),
|
||||
&[],
|
||||
)?
|
||||
.l()?;
|
||||
text(env, value)
|
||||
});
|
||||
}
|
||||
});
|
||||
let finished = match answer {
|
||||
Ok(None) => since.elapsed() > Duration::from_secs(600),
|
||||
Ok(Some(uri)) => {
|
||||
if !uri.is_empty() {
|
||||
if let Some(chosen) = chosen.take() {
|
||||
chosen(uri);
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("{e}");
|
||||
true
|
||||
}
|
||||
};
|
||||
if finished {
|
||||
if let Some(t) = held.borrow().as_ref() {
|
||||
t.stop();
|
||||
}
|
||||
let held = held.clone();
|
||||
slint::Timer::single_shot(Duration::ZERO, move || {
|
||||
held.borrow_mut().take();
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
*slot.borrow_mut() = Some(timer);
|
||||
}
|
||||
|
||||
@@ -176,7 +188,13 @@ pub fn exists(tree: &str, name: &str) -> bool {
|
||||
|
||||
/// Write an export into the folder. Returns the name it has there, which the
|
||||
/// provider may have changed on a collision.
|
||||
pub fn write(tree: &str, name: &str, mime: &str, bytes: &[u8], replace: bool) -> Result<String, String> {
|
||||
pub fn write(
|
||||
tree: &str,
|
||||
name: &str,
|
||||
mime: &str,
|
||||
bytes: &[u8],
|
||||
replace: bool,
|
||||
) -> Result<String, String> {
|
||||
call("writing to the album folder", |env, activity| {
|
||||
let cls = class(env, activity, jni::jni_str!("paris.tourolle.darkroom.Saf"))?;
|
||||
let jtree = env.new_string(tree)?;
|
||||
|
||||
Reference in New Issue
Block a user