Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: drop_events not working #12

Open
github-actions bot opened this issue Nov 27, 2021 · 0 comments
Open

fix: drop_events not working #12

github-actions bot opened this issue Nov 27, 2021 · 0 comments
Labels

Comments

@github-actions
Copy link

fix: drop_events not working

// TODO fix: drop_events not working

use std::time::Instant;

use smart_default::SmartDefault;

use crate::{
    model::{Traffic, Version},
    ui::{
        components::{MovableListItem, MovableListState, ProxyTree},
        Action, Event, InputEvent, UpdateEvent,
    },
    Result,
};

#[derive(Debug, Clone, SmartDefault)]
pub struct TuiStates<'a> {
    pub should_quit: bool,
    #[default(_code = "Instant::now()")]
    pub start_time: Instant,
    pub version: Option<Version>,
    pub traffics: Vec<Traffic>,
    pub max_traffic: Traffic,
    pub events: Vec<Event>,
    pub all_events_recv: usize,
    pub page_index: u8,
    pub show_debug: bool,
    pub proxy_tree: ProxyTree<'a>,
    pub debug_state: MovableListState<'a>,
    pub log_state: MovableListState<'a>,
    pub con_state: MovableListState<'a>,
    pub rule_state: MovableListState<'a>,
    // (upload_size, download_size)
    pub con_size: (u64, u64),
}

// TODO fix: drop_events not working
impl<'a> TuiStates<'a> {
    pub const TITLES: &'static [&'static str] = &[
        "Status", "Proxies", "Rules", "Conns", "Logs", "Configs", "Debug",
    ];

    pub fn handle(&mut self, event: Event) -> Result<Option<Action>> {
        self.all_events_recv += 1;
        if self.events.len() >= 300 {
            drop(self.drop_events(100))
        }
        self.events.push(event.to_owned());
        self.debug_state

ffb00d81ab6e3f629970753180253134ca5908dc

@github-actions github-actions bot added the todo label Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants