slight re factor ing
This commit is contained in:
@@ -34,21 +34,17 @@ impl AppThread {
|
||||
*state = s;
|
||||
}
|
||||
|
||||
fn get_key(&mut self, reason: String) -> anyhow::Result<()> {
|
||||
fn get_key(&mut self, reason: String) -> anyhow::Result<Vec<u8>> {
|
||||
self.commit(UiState::KeyRequired(reason));
|
||||
loop {
|
||||
match self.ui_event_channel.recv()? {
|
||||
UiEvent::SetKey(key) => {
|
||||
self.decryption_key = key;
|
||||
break
|
||||
self.commit(UiState::Loading);
|
||||
return Ok(key);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
self.commit(UiState::Loading);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create(state_holder: &UiStateHolder, context: &egui::Context, ui_event_channel: &Receiver<UiEvent>) -> AppThread {
|
||||
@@ -64,12 +60,16 @@ impl AppThread {
|
||||
self.commit(UiState::Loading);
|
||||
|
||||
let mut config_provider = config::ConfigProvider::new()?;
|
||||
println!("{:?}", config_provider);
|
||||
|
||||
match omori_locator::get_omori_key() {
|
||||
Ok(key) => self.decryption_key = key,
|
||||
Err(reason) => self.get_key(format!("{:?}", reason))?,
|
||||
}
|
||||
|
||||
self.decryption_key = match config_provider.get_key() {
|
||||
Some(key) => key,
|
||||
None => match omori_locator::get_omori_key() {
|
||||
Ok(key) => key,
|
||||
Err(reason) => self.get_key(format!("{:#}", reason))?,
|
||||
}
|
||||
};
|
||||
|
||||
config_provider.set_key(&self.decryption_key)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -77,7 +77,7 @@ impl AppThread {
|
||||
pub fn main(&mut self) {
|
||||
match self.real_main() {
|
||||
Ok(_) => {},
|
||||
Err(e) => self.commit(UiState::Error(format!("{:?}", e))),
|
||||
Err(e) => self.commit(UiState::Error(format!("{:#}", e))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user