From adb581bb58180d76900baa79fc525b8ae3b8ee08 Mon Sep 17 00:00:00 2001 From: Bear Wang Date: Thu, 18 Jan 2024 10:22:12 +0800 Subject: [PATCH] Disable event tab (#47) --- src/app/dashboard/mod.rs | 23 ++++++++++++++--------- src/app/dashboard/tab_events.rs | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/app/dashboard/mod.rs b/src/app/dashboard/mod.rs index f460f82..476fc4c 100644 --- a/src/app/dashboard/mod.rs +++ b/src/app/dashboard/mod.rs @@ -61,7 +61,8 @@ impl<'a, CI: ChainInfo> DashBoard<'a, CI> { events: StatefulList::with_items(VecDeque::with_capacity(EVENTS_MAX_LIMIT)), pallets: StatefulList::with_items(pallets), selected_pallet: None, - tab_titles: vec![String::from("Blocks"), String::from("Events"), String::from("Pallets")], + // tab_titles: vec![String::from("Blocks"), String::from("Events"), String::from("Pallets")], + tab_titles: vec![String::from("Blocks"), String::from("Pallets")], selected_tab: 0, pallet_info_titles: vec![ String::from("Constants"), @@ -85,7 +86,7 @@ impl<'a, CI: ChainInfo> DashBoard<'a, CI> { } } - async fn subscribe_events(&mut self) { + async fn _subscribe_events(&mut self) { fn vec_event_records_type_id(metadata: &mut Metadata) -> Option { let event_records_type_id = metadata .types() @@ -157,7 +158,7 @@ where terminal.draw(|f| ui(f, &mut dash_board))?; dash_board.subscribe_blocks(client.clone()).await; - dash_board.subscribe_events().await; + // dash_board.subscribe_events().await; if let Event::Key(key) = read()? { if key.kind == KeyEventKind::Press { @@ -173,7 +174,8 @@ where dash_board.selected_block = dash_board.blocks.items.get(i).cloned(); } }, - 2 => { + // 2 => { + 1 => { dash_board.pallets.previous(); if let Some(i) = dash_board.pallets.state.selected() { dash_board.selected_pallet = dash_board.pallets.items.get(i).cloned(); @@ -188,7 +190,8 @@ where dash_board.selected_block = dash_board.blocks.items.get(i).cloned(); } }, - 2 => { + // 2 => { + 1 => { dash_board.pallets.next(); if let Some(i) = dash_board.pallets.state.selected() { dash_board.selected_pallet = dash_board.pallets.items.get(i).cloned(); @@ -197,12 +200,14 @@ where _ => {}, }, KeyCode::Right => - if dash_board.selected_tab == 2 { + // if dash_board.selected_tab == 2 { + if dash_board.selected_tab == 1 { dash_board.selected_pallet_info_tab = (dash_board.selected_pallet_info_tab + 1) % dash_board.pallet_info_titles.len(); }, KeyCode::Left => - if dash_board.selected_tab == 2 && dash_board.selected_pallet_info_tab > 0 { + // if dash_board.selected_tab == 2 && dash_board.selected_pallet_info_tab > 0 { + if dash_board.selected_tab == 1 && dash_board.selected_pallet_info_tab > 0 { dash_board.selected_pallet_info_tab -= 1; }, _ => {}, @@ -248,8 +253,8 @@ fn draw_tabs(f: &mut Frame, dash_board: &mut DashBoard, area: match dash_board.selected_tab { 0 => tab_blocks::draw_blocks_tab(f, dash_board, chunks[1]), - 1 => tab_events::draw_events_tab(f, dash_board, chunks[1]), - 2 => tab_pallets::draw_pallets_tab(f, dash_board, chunks[1]), + // 1 => tab_events::draw_events_tab(f, dash_board, chunks[1]), + 1 => tab_pallets::draw_pallets_tab(f, dash_board, chunks[1]), _ => {}, }; } diff --git a/src/app/dashboard/tab_events.rs b/src/app/dashboard/tab_events.rs index 9038b83..c676e0e 100644 --- a/src/app/dashboard/tab_events.rs +++ b/src/app/dashboard/tab_events.rs @@ -8,7 +8,7 @@ use ratatui::{ use super::{DashBoard, EVENTS_MAX_LIMIT}; use crate::networks::ChainInfo; -pub fn draw_events_tab(f: &mut Frame, app: &mut DashBoard, area: Rect) { +pub fn _draw_events_tab(f: &mut Frame, app: &mut DashBoard, area: Rect) { let mut text = "".to_string(); for e in &app.events.items { text.push_str(&format!("{}\n", serde_json::to_string(e).unwrap_or("Decode Error Occurred.".to_string())));