Skip to content

Commit

Permalink
Make timer tab specific
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-001 committed Jan 23, 2024
1 parent 24e9f15 commit 503ddf6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions dolphie/Modules/TabManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from dolphie.Widgets.quick_switch import QuickSwitchHostModal
from textual.app import App
from textual.containers import Container, Horizontal, VerticalScroll
from textual.timer import Timer
from textual.widgets import (
DataTable,
Label,
Expand All @@ -26,6 +27,7 @@ class Tab:
dolphie: Dolphie

worker: Worker = None
worker_timer: Timer = None
worker_cancel_error: str = None

main_container: VerticalScroll = None
Expand Down
8 changes: 3 additions & 5 deletions dolphie/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,13 @@ def on_worker_state_changed(self, event: Worker.StateChanged):
or tab.id != self.tab.id
or dolphie.quick_switched_connection
):
self.worker_timer = self.set_timer(
tab.dolphie.refresh_interval, partial(self.worker_fetch_data, tab.id)
)
tab.worker_timer = self.set_timer(tab.dolphie.refresh_interval, partial(self.worker_fetch_data, tab.id))

return

self.refresh_screen(tab)

self.worker_timer = self.set_timer(tab.dolphie.refresh_interval, partial(self.worker_fetch_data, tab.id))
tab.worker_timer = self.set_timer(tab.dolphie.refresh_interval, partial(self.worker_fetch_data, tab.id))
elif event.state == WorkerState.CANCELLED:
# Only show the modal if there's a worker cancel error
if tab.worker_cancel_error:
Expand Down Expand Up @@ -854,7 +852,7 @@ async def capture_key(self, key):
self.tab.quick_switch_connection()
elif key == "space":
if self.tab.worker.state != WorkerState.RUNNING:
self.worker_timer.stop()
self.tab.worker_timer.stop()
self.worker_fetch_data(self.tab.id)
elif key == "plus":

Expand Down

0 comments on commit 503ddf6

Please sign in to comment.