Skip to content

Commit

Permalink
refactor(app): reorganize App methods for better readability
Browse files Browse the repository at this point in the history
- Move `refresh_objects` method inline into `update` to simplify `App` structure
  • Loading branch information
ShenMian committed Dec 10, 2024
1 parent c019fe2 commit c7c9550
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,16 @@ impl App {

/// Handles the tick event of the terminal.
pub async fn update(&mut self) {
self.refresh_objects().await;
}

/// Set running to false to quit the application.
pub fn quit(&mut self) {
self.running = false;
}

async fn refresh_objects(&mut self) {
const OBJECT_UPDATE_INTERVAL: Duration = Duration::from_secs(2 * 60);
let now = Instant::now();
if now.duration_since(self.satellites_state.last_object_update) >= OBJECT_UPDATE_INTERVAL {
self.satellites_state.refresh_objects().await;
self.satellites_state.last_object_update = now;
}
}

/// Set running to false to quit the application.
pub fn quit(&mut self) {
self.running = false;
}
}

0 comments on commit c7c9550

Please sign in to comment.