mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-24 22:04:53 +01:00
chore(js): added glue workspace functions
This commit is contained in:
parent
2daab9ed87
commit
512c2b30ea
1 changed files with 24 additions and 0 deletions
|
@ -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<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())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue