Skip to content

Commit

Permalink
chore(js): added glue workspace functions
Browse files Browse the repository at this point in the history
  • Loading branch information
frelodev committed Sep 27, 2024
1 parent 2daab9e commit 512c2b3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/ffi/js/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -75,4 +76,27 @@ impl Workspace {
pub async fn js_event(&self) -> napi::Result<JsEvent> {
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<Vec<JsUser>> {
Ok(
self
.list_buffer_users(&path)
.await?
.into_iter()
.map(JsUser::from)
.collect())
}
}

0 comments on commit 512c2b3

Please sign in to comment.