From aecfdbad3350af6a9fc5f9e48c19e39e7b095355 Mon Sep 17 00:00:00 2001 From: SimplifiedPrivacy Date: Wed, 5 Aug 2026 13:17:21 -0400 Subject: [PATCH] Add custom messages to connection observer --- gui/v2/infrastructure/setup_observers.py | 4 ++++ gui/v2/ui/popups/terminal_threading.py | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gui/v2/infrastructure/setup_observers.py b/gui/v2/infrastructure/setup_observers.py index 3811843..41ab3d8 100755 --- a/gui/v2/infrastructure/setup_observers.py +++ b/gui/v2/infrastructure/setup_observers.py @@ -5,6 +5,7 @@ from core.observers.InvoiceObserver import InvoiceObserver from core.observers.ProfileObserver import ProfileObserver from core.observers.TicketObserver import TicketObserver from core.controllers.ApplicationController import ApplicationController +from essentials.models.Event import Event application_version_observer = ApplicationVersionObserver() client_observer = ClientObserver() @@ -56,6 +57,9 @@ def setup_observers(update_status): connection_observer.subscribe( 'tor_bootstrap_progressing', lambda event: update_status(f'{event.subject if event.subject else "Tor Bootstrapping.."}')) + connection_observer.subscribe( + 'message', lambda event: update_status(f'{event.subject if event.subject else "Connecting.."}')) + # original replaced version: # connection_observer.subscribe('tor_bootstrap_progressing', lambda event: update_status( # f'Bootstrapping Tor {event.meta.get('progress'):.2f}%')) diff --git a/gui/v2/ui/popups/terminal_threading.py b/gui/v2/ui/popups/terminal_threading.py index 9d56e53..d736b74 100644 --- a/gui/v2/ui/popups/terminal_threading.py +++ b/gui/v2/ui/popups/terminal_threading.py @@ -1,4 +1,6 @@ -from essentials.observers.ConnectionObserver import ConnectionObserver +from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool + +from core.observers.ConnectionObserver import ConnectionObserver from core.observers.ClientObserver import ClientObserver from core.services.networking.api_requests.ApiResponseModel import ApiResponse, ErrorType from core.controllers.SyncController import new_sync @@ -14,14 +16,9 @@ import traceback from typing import Callable, Any from PyQt6.QtGui import QTextCharFormat - -from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool - import threading from threading import Thread -# mainthread = ThreadSafetyTool() - class NotificationTerminalUI(QDialog): def __init__(self, connection_observer: ConnectionObserver, client_observer: ClientObserver): @@ -34,6 +31,9 @@ class NotificationTerminalUI(QDialog): self.worker_thread = None self.task_success = False + self.connection_observer.subscribe("message", + lambda msg: self.add_notification("UPDATE", msg, "#00ff88")) + self.connection_observer.subscribe("connecting", lambda msg: self.add_notification("CONNECT", msg, "#00ff88"))