From e5dd06a90e6c7609479e1a9819dee08fbe44ee47 Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Sat, 3 May 2025 20:50:03 -0500 Subject: [PATCH] Refactor: Prevent live managers from calling display in update --- src/nba_managers.py | 4 ++-- src/ncaa_bb_managers.py | 8 +++++--- src/ncaa_mb_managers.py | 6 +++--- src/nhl_managers.py | 17 +++++++++++------ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/nba_managers.py b/src/nba_managers.py index 28ec09e7..c457f4b7 100644 --- a/src/nba_managers.py +++ b/src/nba_managers.py @@ -678,9 +678,9 @@ class NBALiveManager(BaseNBAManager): self.current_game = self.live_games[0] self.last_game_switch = current_time - # Always update display when we have new data, but limit to once per second + # Only update display if we have new data and enough time has passed if current_time - self.last_display_update >= 1.0: - self.display(force_clear=True) + # self.display(force_clear=True) # REMOVED: DisplayController handles this self.last_display_update = current_time else: # No live games found diff --git a/src/ncaa_bb_managers.py b/src/ncaa_bb_managers.py index 885b2865..ac8a7057 100644 --- a/src/ncaa_bb_managers.py +++ b/src/ncaa_bb_managers.py @@ -446,8 +446,9 @@ class NCAABBLiveManager(BaseNCAABBMManager): self.current_game = self.live_games[0] if self.live_games else None self.last_game_switch = current_time + # Only update display if we have new data and enough time has passed if current_time - self.last_display_update >= 1.0: - self.display(force_clear=True) + # self.display(force_clear=True) # REMOVED: DisplayController handles this self.last_display_update = current_time else: self.live_games = [] @@ -457,8 +458,9 @@ class NCAABBLiveManager(BaseNCAABBMManager): self.current_game_index = (self.current_game_index + 1) % len(self.live_games) self.current_game = self.live_games[self.current_game_index] self.last_game_switch = current_time - self.display(force_clear=True) - self.last_display_update = current_time + # Force display update when switching games + # self.display(force_clear=True) # REMOVED: DisplayController handles this + self.last_display_update = current_time # Track last successful update that *would* have displayed def _create_live_game_display(self, game_data: Dict[str, Any]) -> Image.Image: """Create a display image for a live NCAA BB game.""" diff --git a/src/ncaa_mb_managers.py b/src/ncaa_mb_managers.py index 85306c31..143978ab 100644 --- a/src/ncaa_mb_managers.py +++ b/src/ncaa_mb_managers.py @@ -703,9 +703,9 @@ class NCAAMBLiveManager(BaseNCAAMBManager): self.last_game_switch = current_time - # Always update display when we have new data, but limit rate - if self.current_game and current_time - self.last_display_update >= 1.0: - self.display(force_clear=True) + # Only update display if we have new data and enough time has passed + if current_time - self.last_display_update >= 1.0: + # self.display(force_clear=True) # REMOVED: DisplayController handles this self.last_display_update = current_time else: # No live games found diff --git a/src/nhl_managers.py b/src/nhl_managers.py index 77e63364..04a6bb6c 100644 --- a/src/nhl_managers.py +++ b/src/nhl_managers.py @@ -639,10 +639,11 @@ class NHLLiveManager(BaseNHLManager): self.current_game = self.live_games[0] self.last_game_switch = current_time - # Always update display when we have new data, but limit to once per second - if current_time - self.last_display_update >= 1.0: - self.display(force_clear=True) + # Update display if data changed, limit rate + if data_changed and current_time - self.last_display_update >= 1.0: + # self.display(force_clear=True) # REMOVED: DisplayController handles this self.last_display_update = current_time + else: # No live games found self.live_games = [] @@ -653,9 +654,13 @@ class NHLLiveManager(BaseNHLManager): self.current_game_index = (self.current_game_index + 1) % len(self.live_games) self.current_game = self.live_games[self.current_game_index] self.last_game_switch = current_time - # Force display update when switching games - self.display(force_clear=True) - self.last_display_update = current_time + # self.display(force_clear=True) # REMOVED: DisplayController handles this + self.last_display_update = current_time # Track time for potential display update + + # If data changed for the *current* game, consider updating display (rate limited) + elif data_changed and current_time - self.last_display_update >= 1.0: + # self.display(force_clear=True) # REMOVED: DisplayController handles this + self.last_display_update = current_time def display(self, force_clear: bool = False): """Display live game information."""