Skip to content

Commit

Permalink
fix: notifications blocked the thread
Browse files Browse the repository at this point in the history
Signed-off-by: Martichou <[email protected]>
  • Loading branch information
Martichou committed Mar 2, 2024
1 parent c690644 commit 566894c
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions frontend/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,30 +246,34 @@ fn send_request_notification(name: String, id: String, app_handle: &AppHandle) {
.show()
{
Ok(n) => {
n.wait_for_action(|action| match action {
"accept" => {
let _ = js2rs(
ChannelMessage {
id,
direction: ChannelDirection::FrontToLib,
action: Some(ChannelAction::AcceptTransfer),
..Default::default()
},
app_handle.state(),
);
}
"reject" => {
let _ = js2rs(
ChannelMessage {
id,
direction: ChannelDirection::FrontToLib,
action: Some(ChannelAction::RejectTransfer),
..Default::default()
},
app_handle.state(),
);
}
_ => (),
let capp_handle = app_handle.clone();
// TODO - Meh, untracked, unwaited tasks...
tokio::task::spawn(async move {
n.wait_for_action(|action| match action {
"accept" => {
let _ = js2rs(
ChannelMessage {
id,
direction: ChannelDirection::FrontToLib,
action: Some(ChannelAction::AcceptTransfer),
..Default::default()
},
capp_handle.state(),
);
}
"reject" => {
let _ = js2rs(
ChannelMessage {
id,
direction: ChannelDirection::FrontToLib,
action: Some(ChannelAction::RejectTransfer),
..Default::default()
},
capp_handle.state(),
);
}
_ => (),
});
});
}
Err(e) => {
Expand Down

0 comments on commit 566894c

Please sign in to comment.