Skip to content

Commit

Permalink
fix(tauri-runtime-wry): tray event listener not registered (#6270)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Feb 14, 2023
1 parent 852e11e commit 138cb8d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-tray-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-runtime-wry": patch
"tauri": patch
---

Fixes tray events not being delivered.
8 changes: 6 additions & 2 deletions core/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2583,14 +2583,18 @@ fn handle_user_message<T: UserEvent>(
Message::Tray(tray_id, tray_message) => {
let mut trays = system_tray_manager.trays.lock().unwrap();

if let TrayMessage::Create(tray, tx) = tray_message {
if let TrayMessage::Create(mut tray, tx) = tray_message {
let mut listeners = Vec::new();
if let Some(l) = tray.on_event.take() {
listeners.push(Arc::new(l));
}
match create_tray(WryTrayId(tray_id), tray, event_loop) {
Ok((tray, items)) => {
trays.insert(
tray_id,
TrayContext {
tray: Arc::new(Mutex::new(Some(tray))),
listeners: Default::default(),
listeners: Arc::new(Mutex::new(listeners)),
items: Arc::new(Mutex::new(items)),
},
);
Expand Down
13 changes: 7 additions & 6 deletions examples/api/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 138cb8d

Please sign in to comment.