mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-17 06:30:50 +01:00
Fix context change propagation to webview extensions
- Added emit_to_all_extensions method to ExtensionWebviewManager - Created webview_extension_emit_to_all Tauri command - Updated UI store to use new command instead of emit() - Broadcasts CONTEXT_CHANGED event to all webview windows - Fixes dynamic context updates not reaching webview extensions
This commit is contained in:
@ -293,6 +293,31 @@ impl ExtensionWebviewManager {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Emits an event to all extension webview windows
|
||||
pub fn emit_to_all_extensions<S: serde::Serialize + Clone>(
|
||||
&self,
|
||||
app_handle: &AppHandle,
|
||||
event: &str,
|
||||
payload: S,
|
||||
) -> Result<(), ExtensionError> {
|
||||
let windows = self.windows.lock().map_err(|e| ExtensionError::MutexPoisoned {
|
||||
reason: e.to_string(),
|
||||
})?;
|
||||
|
||||
// Iterate over all window IDs
|
||||
for window_id in windows.keys() {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if let Some(window) = app_handle.get_webview_window(window_id) {
|
||||
// Emit event to this specific webview window
|
||||
if let Err(e) = window.emit(event, payload.clone()) {
|
||||
eprintln!("Failed to emit event {} to window {}: {}", event, window_id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ExtensionWebviewManager {
|
||||
|
||||
Reference in New Issue
Block a user