Unify SubscriptionsTracked with Span::Update

This commit is contained in:
Héctor Ramón Jiménez 2025-04-21 05:12:08 +02:00
parent 5ce3892a1e
commit a105ad4f9f
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 13 additions and 22 deletions

View file

@ -61,10 +61,6 @@ pub enum Event {
at: SystemTime,
palette: theme::Palette,
},
SubscriptionsTracked {
at: SystemTime,
amount_alive: usize,
},
SpanFinished {
at: SystemTime,
duration: Duration,
@ -84,7 +80,6 @@ impl Event {
Self::Connected { at, .. }
| Self::Disconnected { at, .. }
| Self::ThemeChanged { at, .. }
| Self::SubscriptionsTracked { at, .. }
| Self::SpanFinished { at, .. }
| Self::QuitRequested { at }
| Self::AlreadyRunning { at } => *at,
@ -129,7 +124,8 @@ pub fn run() -> impl Stream<Item = Event> {
let (command_sender, mut command_receiver) = mpsc::channel(1);
let mut last_message = String::new();
let mut last_update_number = 0;
let mut last_commands_spawned = 0;
let mut last_tasks = 0;
let mut last_subscriptions = 0;
let mut last_present_window = None;
drop(task::spawn(async move {
@ -189,12 +185,7 @@ pub fn run() -> impl Stream<Item = Event> {
client::Event::SubscriptionsTracked(
amount_alive,
) => {
let _ = output
.send(Event::SubscriptionsTracked {
at,
amount_alive,
})
.await;
last_subscriptions = amount_alive;
}
client::Event::MessageLogged {
number,
@ -206,13 +197,13 @@ pub fn run() -> impl Stream<Item = Event> {
client::Event::CommandsSpawned(
commands,
) => {
last_commands_spawned = commands;
last_tasks = commands;
}
client::Event::SpanStarted(
span::Stage::Update,
) => {
last_message.clear();
last_commands_spawned = 0;
last_tasks = 0;
}
client::Event::SpanStarted(
span::Stage::Present(window),
@ -231,8 +222,9 @@ pub fn run() -> impl Stream<Item = Event> {
number: last_update_number,
message: last_message
.clone(),
commands_spawned:
last_commands_spawned,
tasks: last_tasks,
subscriptions:
last_subscriptions,
}
}
span::Stage::View(window) => {

View file

@ -8,7 +8,8 @@ pub enum Span {
Update {
number: usize,
message: String,
commands_spawned: usize,
tasks: usize,
subscriptions: usize,
},
View {
window: window::Id,

View file

@ -254,12 +254,10 @@ where
}
},
Event::Program(message) => {
{
self.time_machine.push(&message);
self.time_machine.push(&message);
if self.time_machine.is_rewinding() {
debug::enable();
}
if self.time_machine.is_rewinding() {
debug::enable();
}
let span = debug::update(&message);