54 lines
1.3 KiB
Rust
54 lines
1.3 KiB
Rust
#[cfg(feature = "sycamore")]
|
|
use sycamore::prelude::*;
|
|
|
|
use crate::{event::Event, user::User};
|
|
|
|
#[cfg(feature = "sycamore")]
|
|
use crate::util::ContextOptions;
|
|
|
|
#[cfg(feature = "sycamore")]
|
|
#[derive(Clone, PartialEq, Default)]
|
|
pub struct Users(pub RcSignal<Vec<User>>);
|
|
|
|
#[cfg(not(feature = "sycamore"))]
|
|
#[derive(Clone, PartialEq, Default)]
|
|
pub struct Users;
|
|
|
|
#[cfg(feature = "sycamore")]
|
|
impl Users {
|
|
pub fn get(&self) -> &RcSignal<Vec<User>> {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "sycamore")]
|
|
impl ContextOptions<String> for Users {
|
|
fn options<'a>(&'a self, cx: Scope<'a>) -> &'a ReadSignal<Vec<String>> {
|
|
self.get()
|
|
.map(cx, |v| v.iter().map(|u| u.name.clone()).collect())
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "sycamore")]
|
|
#[derive(Clone, PartialEq, Default)]
|
|
pub struct Events(pub RcSignal<Vec<Event>>);
|
|
|
|
#[cfg(not(feature = "sycamore"))]
|
|
#[derive(Clone, PartialEq, Default)]
|
|
pub struct Events;
|
|
|
|
#[cfg(feature = "sycamore")]
|
|
impl Events {
|
|
pub fn get(&self) -> &RcSignal<Vec<Event>> {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "sycamore")]
|
|
impl ContextOptions<String> for Events {
|
|
fn options<'a>(&'a self, cx: Scope<'a>) -> &'a ReadSignal<Vec<String>> {
|
|
self.get()
|
|
.map(cx, |v| v.iter().map(|u| u.name.clone()).collect())
|
|
}
|
|
}
|