mirror of
https://github.com/pdxlocations/contact.git
synced 2026-08-06 08:53:29 +02:00
move lock to app state
This commit is contained in:
+3
-3
@@ -35,7 +35,7 @@ from contact.utilities.db_handler import init_nodedb, load_messages_from_db
|
||||
from contact.utilities.input_handlers import get_list_input
|
||||
from contact.utilities.interfaces import initialize_interface
|
||||
from contact.utilities.utils import get_channels, get_nodeNum, get_node_list
|
||||
from contact.utilities.singleton import ui_state, interface_state
|
||||
from contact.utilities.singleton import ui_state, interface_state, app_state
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Environment & Logging Setup
|
||||
@@ -51,7 +51,7 @@ logging.basicConfig(
|
||||
filename=config.log_file_path, level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
|
||||
)
|
||||
|
||||
interface_state.lock = threading.Lock()
|
||||
app_state.lock = threading.Lock()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Main Program Logic
|
||||
@@ -95,7 +95,7 @@ def main(stdscr: curses.window) -> None:
|
||||
return
|
||||
|
||||
logging.info("Initializing interface...")
|
||||
with interface_state.lock:
|
||||
with app_state.lock:
|
||||
initialize_globals(args)
|
||||
logging.info("Starting main UI")
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ from contact.utilities.db_handler import (
|
||||
)
|
||||
import contact.ui.default_config as config
|
||||
|
||||
from contact.utilities.singleton import ui_state, interface_state
|
||||
from contact.utilities.singleton import ui_state, interface_state, app_state
|
||||
|
||||
|
||||
def on_receive(packet: Dict[str, Any], interface: Any) -> None:
|
||||
@@ -30,7 +30,7 @@ def on_receive(packet: Dict[str, Any], interface: Any) -> None:
|
||||
packet: The received Meshtastic packet as a dictionary.
|
||||
interface: The Meshtastic interface instance that received the packet.
|
||||
"""
|
||||
with interface_state.lock:
|
||||
with app_state.lock:
|
||||
# Update packet log
|
||||
ui_state.packet_buffer.append(packet)
|
||||
if len(ui_state.packet_buffer) > 20:
|
||||
|
||||
@@ -29,7 +29,9 @@ class ChatUIState:
|
||||
@dataclass
|
||||
class InterfaceState:
|
||||
interface: Any = None
|
||||
lock: Any = None
|
||||
myNodeNum: int = 0
|
||||
# menu_state: MenuState = field(default_factory=MenuState)
|
||||
# chat_ui_state: ChatUIState = field(default_factory=ChatUIState)
|
||||
|
||||
|
||||
@dataclass
|
||||
class AppState:
|
||||
lock: Any = None
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from ui.ui_state import ChatUIState
|
||||
from ui.ui_state import InterfaceState
|
||||
from ui.ui_state import ChatUIState, InterfaceState, AppState
|
||||
|
||||
ui_state = ChatUIState()
|
||||
interface_state = InterfaceState()
|
||||
app_state = AppState()
|
||||
|
||||
Reference in New Issue
Block a user