mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-24 16:14:48 +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::Workspace;
|
||||||
use crate::buffer::controller::BufferController;
|
use crate::buffer::controller::BufferController;
|
||||||
use crate::cursor::controller::CursorController;
|
use crate::cursor::controller::CursorController;
|
||||||
|
use crate::ffi::js::client::JsUser;
|
||||||
|
|
||||||
#[napi(object, js_name = "Event")]
|
#[napi(object, js_name = "Event")]
|
||||||
pub struct JsEvent {
|
pub struct JsEvent {
|
||||||
|
@ -75,4 +76,27 @@ impl Workspace {
|
||||||
pub async fn js_event(&self) -> napi::Result<JsEvent> {
|
pub async fn js_event(&self) -> napi::Result<JsEvent> {
|
||||||
Ok(JsEvent::from(self.event().await?))
|
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