fix(tauri-runtime-wry): tray event listener not registered (#6270)

This commit is contained in:
Lucas Fernandes Nogueira 2023-02-14 09:56:36 -08:00 committed by Lucas Nogueira
parent 5ab78fcafa
commit b9c303a0dc
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1
2 changed files with 12 additions and 2 deletions

View File

@ -0,0 +1,6 @@
---
"tauri-runtime-wry": patch
"tauri": patch
---
Fixes tray events not being delivered.

View File

@ -2647,14 +2647,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)),
},
);