//! Tauri event helpers for the research subsystem.

use serde::Serialize;
use tauri::{AppHandle, Emitter, Runtime};

#[derive(Debug)]
pub struct ResearchEventEmitter<R: Runtime> {
    app_handle: AppHandle<R>,
}

impl<R: Runtime> Clone for ResearchEventEmitter<R> {
    fn clone(&self) -> Self {
        Self {
            app_handle: self.app_handle.clone(),
        }
    }
}

impl<R: Runtime> ResearchEventEmitter<R> {
    pub fn new(app_handle: &AppHandle<R>) -> Self {
        Self {
            app_handle: app_handle.clone(),
        }
    }

    pub fn workspace_updated<T: Serialize>(&self, payload: &T) {
        let _ = self.app_handle.emit("research_workspace_updated", payload);
    }

    pub fn note_updated<T: Serialize>(&self, payload: &T) {
        let _ = self.app_handle.emit("research_note_updated", payload);
    }

    pub fn ghost_updated<T: Serialize>(&self, payload: &T) {
        let _ = self.app_handle.emit("research_ghost_updated", payload);
    }

    pub fn job_updated<T: Serialize>(&self, payload: &T) {
        let _ = self.app_handle.emit("research_job_updated", payload);
    }
}
