wip: refactor
This commit is contained in:
2
crates/app/src/states/mod.rs
Normal file
2
crates/app/src/states/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod room;
|
||||
pub mod user;
|
||||
35
crates/app/src/states/room.rs
Normal file
35
crates/app/src/states/room.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use gpui::*;
|
||||
use nostr_sdk::prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct RoomLastMessage {
|
||||
pub content: Option<String>,
|
||||
pub time: Timestamp,
|
||||
}
|
||||
|
||||
#[derive(Clone, IntoElement)]
|
||||
pub struct Room {
|
||||
members: Vec<PublicKey>,
|
||||
last_message: Option<RoomLastMessage>,
|
||||
}
|
||||
|
||||
impl Room {
|
||||
pub fn new(members: Vec<PublicKey>, last_message: Option<RoomLastMessage>) -> Self {
|
||||
Self {
|
||||
members,
|
||||
last_message,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderOnce for Room {
|
||||
fn render(self, _cx: &mut WindowContext) -> impl IntoElement {
|
||||
div().child("TODO")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Rooms {
|
||||
pub rooms: Vec<Room>,
|
||||
}
|
||||
|
||||
impl Global for Rooms {}
|
||||
19
crates/app/src/states/user.rs
Normal file
19
crates/app/src/states/user.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use gpui::*;
|
||||
use nostr_sdk::prelude::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct UserState {
|
||||
pub current_user: Option<PublicKey>,
|
||||
}
|
||||
|
||||
impl Global for UserState {}
|
||||
|
||||
impl UserState {
|
||||
pub fn set_global(cx: &mut AppContext) {
|
||||
cx.set_global(Self::new());
|
||||
}
|
||||
|
||||
fn new() -> Self {
|
||||
Self { current_user: None }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user