app: add reconnection status to status bar
This commit is contained in:
@@ -75,6 +75,7 @@ class StatusBar(Static):
|
|||||||
|
|
||||||
ptt_active = reactive(False)
|
ptt_active = reactive(False)
|
||||||
connected = reactive(False)
|
connected = reactive(False)
|
||||||
|
reconnecting = reactive(False)
|
||||||
self_deaf = reactive(False)
|
self_deaf = reactive(False)
|
||||||
server_info = reactive("")
|
server_info = reactive("")
|
||||||
output_vol = reactive(100)
|
output_vol = reactive(100)
|
||||||
@@ -92,6 +93,9 @@ class StatusBar(Static):
|
|||||||
if self.connected:
|
if self.connected:
|
||||||
conn_sym = "[#9ece6a]\u25cf[/]"
|
conn_sym = "[#9ece6a]\u25cf[/]"
|
||||||
conn_full = f"{conn_sym} connected"
|
conn_full = f"{conn_sym} connected"
|
||||||
|
elif self.reconnecting:
|
||||||
|
conn_sym = "[#e0af68]\u25d0[/]"
|
||||||
|
conn_full = f"{conn_sym} reconnecting"
|
||||||
else:
|
else:
|
||||||
conn_sym = "[#f7768e]\u25cb[/]"
|
conn_sym = "[#f7768e]\u25cb[/]"
|
||||||
conn_full = f"{conn_sym} disconnected"
|
conn_full = f"{conn_sym} disconnected"
|
||||||
@@ -538,6 +542,8 @@ class TuimbleApp(App):
|
|||||||
|
|
||||||
def _log_reconnect(self, attempt: int, delay: int) -> None:
|
def _log_reconnect(self, attempt: int, delay: int) -> None:
|
||||||
"""Log reconnection attempt to chatlog."""
|
"""Log reconnection attempt to chatlog."""
|
||||||
|
status = self.query_one("#status", StatusBar)
|
||||||
|
status.reconnecting = True
|
||||||
chatlog = self.query_one("#chatlog", ChatLog)
|
chatlog = self.query_one("#chatlog", ChatLog)
|
||||||
chatlog.write(
|
chatlog.write(
|
||||||
f"[dim]reconnecting in {delay}s "
|
f"[dim]reconnecting in {delay}s "
|
||||||
@@ -550,6 +556,8 @@ class TuimbleApp(App):
|
|||||||
|
|
||||||
def _on_reconnect_exhausted(self) -> None:
|
def _on_reconnect_exhausted(self) -> None:
|
||||||
"""Handle all reconnection attempts exhausted."""
|
"""Handle all reconnection attempts exhausted."""
|
||||||
|
status = self.query_one("#status", StatusBar)
|
||||||
|
status.reconnecting = False
|
||||||
chatlog = self.query_one("#chatlog", ChatLog)
|
chatlog = self.query_one("#chatlog", ChatLog)
|
||||||
chatlog.write(
|
chatlog.write(
|
||||||
f"[#f7768e]reconnection failed after "
|
f"[#f7768e]reconnection failed after "
|
||||||
@@ -561,6 +569,11 @@ class TuimbleApp(App):
|
|||||||
"""Cancel an in-progress reconnect loop."""
|
"""Cancel an in-progress reconnect loop."""
|
||||||
self._reconnecting = False
|
self._reconnecting = False
|
||||||
self._reconnect_attempt = 0
|
self._reconnect_attempt = 0
|
||||||
|
try:
|
||||||
|
status = self.query_one("#status", StatusBar)
|
||||||
|
status.reconnecting = False
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# -- message handlers ----------------------------------------------------
|
# -- message handlers ----------------------------------------------------
|
||||||
|
|
||||||
@@ -568,6 +581,7 @@ class TuimbleApp(App):
|
|||||||
self._intentional_disconnect = False
|
self._intentional_disconnect = False
|
||||||
|
|
||||||
status = self.query_one("#status", StatusBar)
|
status = self.query_one("#status", StatusBar)
|
||||||
|
status.reconnecting = False
|
||||||
status.connected = True
|
status.connected = True
|
||||||
srv = self._config.server
|
srv = self._config.server
|
||||||
status.server_info = f"{srv.host}:{srv.port}"
|
status.server_info = f"{srv.host}:{srv.port}"
|
||||||
|
|||||||
Reference in New Issue
Block a user