Skip to content

Commit 643ae84

Browse files
authored
fix: fire window-specific event on Window emit_to/emit_all, closes #4493 (#4498)
1 parent b857a00 commit 643ae84

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.changes/fix-window-emit-target.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Properly fill the origin window when using `emit_to` and `emit_all` from `Window`.

core/tauri/src/window.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,24 @@ impl<R: Runtime> PartialEq for Window<R> {
520520
}
521521
}
522522

523-
impl<R: Runtime> Manager<R> for Window<R> {}
523+
impl<R: Runtime> Manager<R> for Window<R> {
524+
fn emit_to<S: Serialize + Clone>(
525+
&self,
526+
label: &str,
527+
event: &str,
528+
payload: S,
529+
) -> crate::Result<()> {
530+
self
531+
.manager()
532+
.emit_filter(event, Some(self.label()), payload, |w| label == w.label())
533+
}
534+
535+
fn emit_all<S: Serialize + Clone>(&self, event: &str, payload: S) -> crate::Result<()> {
536+
self
537+
.manager()
538+
.emit_filter(event, Some(self.label()), payload, |_| true)
539+
}
540+
}
524541
impl<R: Runtime> ManagerBase<R> for Window<R> {
525542
fn manager(&self) -> &WindowManager<R> {
526543
&self.manager
@@ -1339,6 +1356,7 @@ impl<R: Runtime> Window<R> {
13391356
source_window_label: Option<&str>,
13401357
payload: S,
13411358
) -> crate::Result<()> {
1359+
println!("emit internal {:?} {:?}", event, source_window_label);
13421360
self.eval(&format!(
13431361
"window['{}']({{event: {}, windowLabel: {}, payload: {}}})",
13441362
self.manager.event_emit_function_name(),

0 commit comments

Comments
 (0)