@@ -2,10 +2,7 @@ use crate::Workspace;
22use crate :: api:: controller:: AsyncReceiver ;
33use crate :: buffer:: controller:: BufferController ;
44use crate :: cursor:: controller:: CursorController ;
5- use napi:: threadsafe_function:: ErrorStrategy :: Fatal ;
6- use napi:: threadsafe_function:: {
7- ThreadSafeCallContext , ThreadsafeFunction , ThreadsafeFunctionCallMode ,
8- } ;
5+ use napi:: threadsafe_function:: { ThreadsafeFunction , ThreadsafeFunctionCallMode } ;
96use napi_derive:: napi;
107
118use super :: client:: JsUser ;
@@ -45,8 +42,8 @@ impl Workspace {
4542
4643 /// List all available buffers in this workspace
4744 #[ napi( js_name = "searchBuffers" ) ]
48- pub fn js_search_buffers ( & self , filter : Option < & str > ) -> Vec < String > {
49- self . search_buffers ( filter)
45+ pub fn js_search_buffers ( & self , filter : Option < String > ) -> Vec < String > {
46+ self . search_buffers ( filter. as_deref ( ) )
5047 }
5148
5249 /// List all user names currently in this workspace
@@ -114,13 +111,10 @@ impl Workspace {
114111 }
115112
116113 #[ napi( js_name = "callback" , ts_args_type = "fun: (event: Workspace) => void" ) ]
117- pub fn js_callback ( & self , fun : napi:: JsFunction ) -> napi:: Result < ( ) > {
118- let tsfn: ThreadsafeFunction < crate :: Workspace , Fatal > = fun
119- . create_threadsafe_function ( 0 , |ctx : ThreadSafeCallContext < crate :: Workspace > | {
120- Ok ( vec ! [ ctx. value] )
121- } ) ?;
114+ pub fn js_callback ( & self , fun : ThreadsafeFunction < Workspace > ) -> napi:: Result < ( ) > {
115+ let tsfn: ThreadsafeFunction < crate :: Workspace > = fun;
122116 self . callback ( move |controller : Workspace | {
123- tsfn. call ( controller. clone ( ) , ThreadsafeFunctionCallMode :: Blocking ) ; //check this with tracing also we could use Ok(event) to get the error
117+ tsfn. call ( Ok ( controller. clone ( ) ) , ThreadsafeFunctionCallMode :: Blocking ) ; //check this with tracing also we could use Ok(event) to get the error
124118 // If it blocks the main thread too many time we have to change this
125119 } ) ;
126120
0 commit comments