fn refresh_node_visualization(&self, id: graph_editor::NodeId, node: &controller::graph::Node) {
        let path_in_metadata = node.metadata.as_ref().and_then(|md| {
            // It is perfectly fine to ignore deserialization errors here. This is metadata, that
            // might not even be initialized.
            serde_json::from_value(md.visualization.clone()).ok()
        });

        let visualization_frp = match self.view.graph().model.nodes.all.get_cloned_ref(&id) {
            Some(node) => node.model.visualization.frp.clone_ref(),
            // If there is no node view, there is nothing to be done with visualization view.
            None => return,
        };
        let is_visible = visualization_frp.visible.value();
        let path_in_visible_visualization = is_visible
            .and_option(visualization_frp.visualisation.value())
            .map(|definition| definition.path());

        if path_in_visible_visualization != path_in_metadata {
            if path_in_metadata.is_some() {
                let visualization = (id, path_in_metadata);
                self.view.graph().frp.input.set_visualization.emit(&visualization);
                self.view.graph().frp.input.enable_visualization.emit(&id);
            } else {
                self.view.graph().frp.input.disable_visualization.emit(&id);
            }
        }
    }
/// Update the enabled visualization on a node to follow the metadata.
Update the enabled visualization on a node to follow the metadata.
Update the enabled visualization on a node to follow the metadata .
fn refresh_node_visualization(&self, id: graph_editor::NodeId, node: &controller::graph::Node) {
        let path_in_metadata = node.metadata.as_ref().and_then(|md| {
            // It is perfectly fine to ignore deserialization errors here. This is metadata, that
            // might not even be initialized.
            serde_json::from_value(md.visualization.clone()).ok()
        });
        let visualization_frp = match self.view.graph().model.nodes.all.get_cloned_ref(&id) {
            Some(node) => node.model.visualization.frp.clone_ref(),
            // If there is no node view, there is nothing to be done with visualization view.
            None => return,
        };
        let is_visible = visualization_frp.visible.value();
        let path_in_visible_visualization = is_visible
            .and_option(visualization_frp.visualisation.value())
            .map(|definition| definition.path());
        if path_in_visible_visualization != path_in_metadata {
            if path_in_metadata.is_some() {
                let visualization = (id, path_in_metadata);
                self.view.graph().frp.input.set_visualization.emit(&visualization);
                self.view.graph().frp.input.enable_visualization.emit(&id);
            } else {
                self.view.graph().frp.input.disable_visualization.emit(&id);
            }
        }
    }
fn refresh_node_visualization ( & self , id : graph_editor :: NodeId , node : & controller :: graph :: Node ) { let path_in_metadata = node . metadata . as_ref ( ) . and_then ( | md | { // It is perfectly fine to ignore deserialization errors here. This is metadata, that // might not even be initialized. serde_json :: from_value ( md . visualization . clone ( ) ) . ok ( ) } ) ; let visualization_frp = match self . view . graph ( ) . model . nodes . all . get_cloned_ref ( & id ) { Some ( node ) => node . model . visualization . frp . clone_ref ( ) , // If there is no node view, there is nothing to be done with visualization view. None => return , } ; let is_visible = visualization_frp . visible . value ( ) ; let path_in_visible_visualization = is_visible . and_option ( visualization_frp . visualisation . value ( ) ) . map ( | definition | definition . path ( ) ) ; if path_in_visible_visualization != path_in_metadata { if path_in_metadata . is_some ( ) { let visualization = ( id , path_in_metadata ) ; self . view . graph ( ) . frp . input . set_visualization . emit ( & visualization ) ; self . view . graph ( ) . frp . input . enable_visualization . emit ( & id ) ; } else { self . view . graph ( ) . frp . input . disable_visualization . emit ( & id ) ; } } }
Update the enabled visualization on a node to follow the metadata.
Update the enabled visualization on a node to follow the metadata .
&self
id
graph_editor::NodeId
node
&controller::graph::Node
&self
id
graph_editor::NodeId
node
&controller::graph::Node