mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 00:28:12 +08:00
Desktop: Buffer web messages until connection is initialized (#3082)
Buffer web messages until connection is initialized
This commit is contained in:
@@ -242,6 +242,9 @@ impl EditorHandle {
|
||||
|
||||
#[wasm_bindgen(js_name = initAfterFrontendReady)]
|
||||
pub fn init_after_frontend_ready(&self, platform: String) {
|
||||
#[cfg(feature = "native")]
|
||||
crate::native_communcation::initialize_native_communication();
|
||||
|
||||
// Send initialization messages
|
||||
let platform = match platform.as_str() {
|
||||
"Windows" => Platform::Windows,
|
||||
|
||||
@@ -20,6 +20,17 @@ pub fn receive_native_message(buffer: ArrayBuffer) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn initialize_native_communication() {
|
||||
let global = js_sys::global();
|
||||
|
||||
// Get the function by name
|
||||
let func = js_sys::Reflect::get(&global, &JsValue::from_str("initializeNativeCommunication")).expect("Function not found");
|
||||
let func = func.dyn_into::<js_sys::Function>().expect("Not a function");
|
||||
|
||||
// Call it
|
||||
func.call0(&JsValue::NULL).expect("Function call failed");
|
||||
}
|
||||
|
||||
pub fn send_message_to_cef(message: String) {
|
||||
let global = js_sys::global();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user