diff --git a/src/ffi/js/workspace.rs b/src/ffi/js/workspace.rs index 1dd43d5..3d003c7 100644 --- a/src/ffi/js/workspace.rs +++ b/src/ffi/js/workspace.rs @@ -2,6 +2,7 @@ use napi_derive::napi; use crate::Workspace; use crate::buffer::controller::BufferController; use crate::cursor::controller::CursorController; +use crate::ffi::js::client::JsUser; #[napi(object, js_name = "Event")] pub struct JsEvent { @@ -75,4 +76,27 @@ impl Workspace { pub async fn js_event(&self) -> napi::Result { Ok(JsEvent::from(self.event().await?)) } + + /// Re-fetch remote buffer list + #[napi(js_name = "fetch_buffers")] + pub async fn js_fetch_buffers(&self) -> napi::Result<()> { + Ok(self.fetch_buffers().await?) + } + /// Re-fetch the list of all users in the workspace. + #[napi(js_name = "fetch_users")] + pub async fn js_fetch_users(&self) -> napi::Result<()> { + Ok(self.fetch_users().await?) + } + + /// List users attached to a specific buffer + #[napi(js_name = "list_buffer_users")] + pub async fn js_list_buffer_users(&self, path: String) -> napi::Result> { + Ok( + self + .list_buffer_users(&path) + .await? + .into_iter() + .map(JsUser::from) + .collect()) + } }