Skip to content

Commit

Permalink
Merge pull request #18 from probe-rs/Don-t-copy-state-for-each-node
Browse files Browse the repository at this point in the history
Don't copy state for each node
  • Loading branch information
Tiwalun authored Feb 19, 2024
2 parents 0585cf5 + 2e27ea0 commit 83aeb84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/info_node.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::rc::Rc;

use yew::{
classes, function_component, html, use_state, Callback, Html, Properties, UseStateHandle,
};
Expand All @@ -12,7 +14,7 @@ use log_viewer::{

#[derive(Clone, PartialEq, Properties)]
pub struct InfoNodeProps {
pub state: State,
pub state: Rc<State>,
pub node_index: usize,
pub level_filter: UseStateHandle<LevelFilter>,
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod pill;

use std::{
collections::{BTreeMap, HashMap},
rc::Rc,
str::FromStr,
};

Expand Down Expand Up @@ -321,7 +322,7 @@ fn App() -> Html {
<button onclick={oncreate} class={classes!["ml-3","my-3", "px-2", "py-1", "border", "border-black"]}>{"Create"}</button>
<div class="m-3">
{match (&*gist, &*state) {
(Ok(_gist), Some(state)) => html!{<InfoNode state={state.clone()} node_index={0} level_filter={level_filter.clone()} />},
(Ok(_gist), Some(state)) => html!{<InfoNode state={Rc::new(state.clone())} node_index={0} level_filter={level_filter.clone()} />},
(Err(error), _) => error.to_string().into(),
_ => unreachable!()
}}
Expand Down

0 comments on commit 83aeb84

Please sign in to comment.