Skip to content

Commit 278b442

Browse files
committed
Pass channel_id
1 parent cd3518a commit 278b442

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

client/src/components/mindmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use dioxus::prelude::*;
1010
use std::rc::Rc;
1111

1212
#[component]
13-
pub fn Mindmap() -> Element {
14-
let store = Store::new();
13+
pub fn Mindmap(channel_id: String) -> Element {
14+
let store = Store::new(channel_id);
1515
let mut pane = store.pane;
1616
let mut graph = store.graph;
1717

client/src/data/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct Connection {
1919
}
2020

2121
impl Connection {
22-
pub fn new(graph: Graph) -> Self {
22+
pub fn new(graph: Graph, channel_id: String) -> Self {
2323
let doc = graph.get_doc();
2424
let coroutine = use_coroutine(move |mut rx: UnboundedReceiver<Message>| {
2525
let mut doc = doc;

client/src/data/store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pub struct Store {
1010
}
1111

1212
impl Store {
13-
pub fn new() -> Self {
13+
pub fn new(channel_id: String) -> Self {
1414
let graph = Graph::new();
1515
Self {
1616
graph,
1717
pane: Pane::new(),
18-
connection: Connection::new(graph),
18+
connection: Connection::new(graph, channel_id),
1919
}
2020
}
2121
}

client/src/router.rs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,41 @@ pub enum Route {
2121
#[component]
2222
fn Home() -> Element {
2323
rsx! {
24-
document::Style {
25-
{
26-
format!(
27-
" @font-face {{ font-family: 'Roboto Light'; src: url({}) format('truetype');}} ",
28-
asset!("/assets/fonts/Roboto-Light.ttf"),
29-
)
30-
}
24+
default_style {}
25+
h1 {
26+
"Welcome! Create a mindmap by navigating to /channels/YOUR_CHANNEL_NAME"
3127
}
32-
document::Link { rel: "icon", href: FAVICON }
33-
document::Link { rel: "stylesheet", href: MAIN_CSS }
34-
Mindmap {}
3528
}
3629
}
3730

3831
#[component]
3932
fn Channel(channel_id: String) -> Element {
40-
rsx! { "Channel page for channel with id: {channel_id}" }
33+
rsx! {
34+
default_style {}
35+
Mindmap { channel_id: "root" }
36+
}
4137
}
4238

4339
#[component]
4440
fn NotFound(any: String) -> Element {
4541
// TODO: Return 404 status code
46-
rsx! { "Not found :(" }
42+
rsx! {
43+
default_style {}
44+
p { "Not found :(" }
45+
}
46+
}
47+
48+
fn default_style() -> Element {
49+
rsx! {
50+
document::Style {
51+
{
52+
format!(
53+
" @font-face {{ font-family: 'Roboto Light'; src: url({}) format('truetype');}} ",
54+
asset!("/assets/fonts/Roboto-Light.ttf"),
55+
)
56+
}
57+
}
58+
document::Link { rel: "icon", href: FAVICON }
59+
document::Link { rel: "stylesheet", href: MAIN_CSS }
60+
}
4761
}

0 commit comments

Comments
 (0)