remove some unwraps
This commit is contained in:
parent
a027922b0e
commit
055df38c32
1 changed files with 20 additions and 16 deletions
|
@ -127,27 +127,30 @@ mod imp {
|
|||
}
|
||||
|
||||
async fn save(&self) {
|
||||
assert!(self.obj().authn_can_edit());
|
||||
self.obj().set_authn_can_edit(false);
|
||||
|
||||
// TODO remove unwraps etc etc
|
||||
let keyring = oo7::Keyring::new().await.unwrap();
|
||||
let mut attributes = vec![("xdg:schema", crate::APP_ID.to_string())];
|
||||
// clear previous passwords
|
||||
keyring.delete(&attributes).await.unwrap();
|
||||
async fn wrapper(self_: &Setup) -> Result<(), impl std::error::Error> {
|
||||
let keyring = oo7::Keyring::new().await?;
|
||||
let mut attributes = vec![("xdg:schema", crate::APP_ID.to_string())];
|
||||
// clear previous passwords
|
||||
keyring.delete(&attributes).await?;
|
||||
|
||||
attributes.push(("server-url", self.obj().server_url()));
|
||||
attributes.push(("username", self.obj().username()));
|
||||
keyring
|
||||
.create_item(
|
||||
"Audrey Subsonic password",
|
||||
&attributes,
|
||||
self.obj().password(),
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
attributes.push(("server-url", self_.obj().server_url()));
|
||||
attributes.push(("username", self_.obj().username()));
|
||||
keyring
|
||||
.create_item(
|
||||
"Audrey Subsonic password",
|
||||
&attributes,
|
||||
self_.obj().password(),
|
||||
true,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
let result = wrapper(self).await;
|
||||
self.obj().set_authn_can_edit(true);
|
||||
result.unwrap(); // FIXME
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,6 +170,7 @@ impl Setup {
|
|||
#[weak(rename_to = self_)]
|
||||
self,
|
||||
async move {
|
||||
assert!(self_.authn_can_edit())
|
||||
self_.set_authn_can_edit(false);
|
||||
|
||||
// TODO remove unwraps, make sure authn_can_edit is set back to true
|
||||
|
|
Loading…
Reference in a new issue