feat: user_list returns Vec<User>

returning a String was weird!
This commit is contained in:
əlemi 2024-10-15 22:19:38 +02:00
parent 14e10e1f7b
commit a44edee07b
Signed by: alemi
GPG key ID: A4895B84D311642C
4 changed files with 9 additions and 7 deletions

View file

@ -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()
}

View file

@ -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

View file

@ -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()
}

View file

@ -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()
}