mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-23 05:14:54 +01:00
feat: user_list returns Vec<User>
returning a String was weird!
This commit is contained in:
parent
14e10e1f7b
commit
a44edee07b
4 changed files with 9 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
api::controller::AsyncReceiver,
|
||||
api::{controller::AsyncReceiver, User},
|
||||
errors::{ConnectionError, ControllerError, RemoteError},
|
||||
ffi::java::null_check,
|
||||
Workspace,
|
||||
|
@ -39,7 +39,7 @@ fn active_buffers(workspace: &mut Workspace) -> Vec<String> {
|
|||
|
||||
/// Gets a list of the active buffers.
|
||||
#[jni(package = "mp.code", class = "Workspace")]
|
||||
fn user_list(workspace: &mut Workspace) -> Vec<String> {
|
||||
fn user_list(workspace: &mut Workspace) -> Vec<User> {
|
||||
workspace.user_list()
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ use napi::threadsafe_function::{
|
|||
};
|
||||
use napi_derive::napi;
|
||||
|
||||
use super::client::JsUser;
|
||||
|
||||
#[napi(object, js_name = "Event")]
|
||||
pub struct JsEvent {
|
||||
pub r#type: String,
|
||||
|
@ -49,8 +51,8 @@ impl Workspace {
|
|||
|
||||
/// List all user names currently in this workspace
|
||||
#[napi(js_name = "user_list")]
|
||||
pub fn js_user_list(&self) -> Vec<String> {
|
||||
self.user_list()
|
||||
pub fn js_user_list(&self) -> Vec<JsUser> {
|
||||
self.user_list().into_iter().map(JsUser::from).collect()
|
||||
}
|
||||
|
||||
/// List all currently active buffers
|
||||
|
|
|
@ -80,7 +80,7 @@ impl Workspace {
|
|||
}
|
||||
|
||||
#[pyo3(name = "user_list")]
|
||||
fn pyuser_list(&self) -> Vec<String> {
|
||||
fn pyuser_list(&self) -> Vec<User> {
|
||||
self.user_list()
|
||||
}
|
||||
|
||||
|
|
|
@ -300,11 +300,11 @@ impl Workspace {
|
|||
}
|
||||
|
||||
/// Get all names of users currently in this workspace
|
||||
pub fn user_list(&self) -> Vec<String> {
|
||||
pub fn user_list(&self) -> Vec<User> {
|
||||
self.0
|
||||
.users
|
||||
.iter()
|
||||
.map(|elem| elem.value().name.clone())
|
||||
.map(|elem| elem.value().clone())
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue