feat: Kill monero-wallet-rpc on GUI exit

This commit is contained in:
binarybaron 2024-08-09 23:34:21 +02:00
parent acdb0231b5
commit 718132b8b4
No known key found for this signature in database
GPG key ID: 99B75D3E1476A26E
3 changed files with 37 additions and 10 deletions

View file

@ -11,7 +11,7 @@ use swap::{
},
cli::command::{Bitcoin, Monero},
};
use tauri::{Manager, State};
use tauri::{Manager, RunEvent, State};
trait ToStringResult<T> {
fn to_string_result(self) -> Result<T, String>;
@ -107,6 +107,16 @@ pub fn run() {
withdraw_btc
])
.setup(setup)
.run(tauri::generate_context!())
.expect("error while running tauri application");
.build(tauri::generate_context!())
.expect("error while building tauri application")
.run(|app, event| match event {
RunEvent::Exit | RunEvent::ExitRequested { .. } => {
let context = app.state::<Arc<Context>>().inner();
if let Err(err) = context.cleanup() {
println!("Cleanup failed {}", err);
}
}
_ => {}
})
}