we reduce boilerplate by creating a new generic function called draw().
variables are initialized in draw_outbound(), draw_inbound(), and
draw_manual() and are then sent to draw().
dynamic resizing is enabled by returning the total frame length like so:
let len = draw_outbound(...)
let len = draw_inbound(..., len)
it would be cleaner to store this value in a struct. however this is non
trivial to implement.
ui::ui() cannot be async and therefore cannot use mutexes due to its use
in the following non-async function from external library tui::Terminal:
terminal.draw(|f| {
ui::ui(f, view.clone());
})?;
however ui::ui() is called within the async function render(), which
means values set inside ui::ui() may be overwritten during async calls.
let external_addr = addr.as_str().unwrap()
^ this line was crashing when we receive a Null value for external_addr.
we now set the string value to "Null" if external_addr.is_null()
created seperate functions to render the different data types. frames
dynamically resize according to the length of the data. we do this by
keeping track of the previous length and passing it into each new render.
there's a lot of boilerplate rn that needs to be cleaned up, and the
dynamic resizing can probably be further simplified.
NodeId is read from config and is initalized into Model.
The values from Model are then copied into View.
We therefore do not need to read this data in the UI, as it already exists in View.
node_info = HashMap<NodeId, NodeInfo>
If we receive an external addr from the rpc data, we set that as the NodeID.
otherwise we display client's rpc port as the NodeID.
Note: this is a temporary solution until we add a 'name' param to the
config. This commit indicates a number of TODOs.
as the values may be null we cannot parse using this form:
let foo: Foo = serde_json::from_value(bar)
manual_connect is the exception to this as right now we are just parsing
dummy data which is never null.
otherwise if the data is empty we simply write empty values to NodeInfo.
this will be rendered as Null in ui::ui()