Add custom messages to connection observer

This commit is contained in:
SimplifiedPrivacy 2026-08-05 13:17:21 -04:00
parent 745c465cf2
commit aecfdbad33
2 changed files with 10 additions and 6 deletions

View file

@ -5,6 +5,7 @@ from core.observers.InvoiceObserver import InvoiceObserver
from core.observers.ProfileObserver import ProfileObserver from core.observers.ProfileObserver import ProfileObserver
from core.observers.TicketObserver import TicketObserver from core.observers.TicketObserver import TicketObserver
from core.controllers.ApplicationController import ApplicationController from core.controllers.ApplicationController import ApplicationController
from essentials.models.Event import Event
application_version_observer = ApplicationVersionObserver() application_version_observer = ApplicationVersionObserver()
client_observer = ClientObserver() client_observer = ClientObserver()
@ -56,6 +57,9 @@ def setup_observers(update_status):
connection_observer.subscribe( connection_observer.subscribe(
'tor_bootstrap_progressing', lambda event: update_status(f'{event.subject if event.subject else "Tor Bootstrapping.."}')) '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: # original replaced version:
# connection_observer.subscribe('tor_bootstrap_progressing', lambda event: update_status( # connection_observer.subscribe('tor_bootstrap_progressing', lambda event: update_status(
# f'Bootstrapping Tor {event.meta.get('progress'):.2f}%')) # f'Bootstrapping Tor {event.meta.get('progress'):.2f}%'))

View file

@ -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.observers.ClientObserver import ClientObserver
from core.services.networking.api_requests.ApiResponseModel import ApiResponse, ErrorType from core.services.networking.api_requests.ApiResponseModel import ApiResponse, ErrorType
from core.controllers.SyncController import new_sync from core.controllers.SyncController import new_sync
@ -14,14 +16,9 @@ import traceback
from typing import Callable, Any from typing import Callable, Any
from PyQt6.QtGui import QTextCharFormat from PyQt6.QtGui import QTextCharFormat
from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
import threading import threading
from threading import Thread from threading import Thread
# mainthread = ThreadSafetyTool()
class NotificationTerminalUI(QDialog): class NotificationTerminalUI(QDialog):
def __init__(self, connection_observer: ConnectionObserver, client_observer: ClientObserver): def __init__(self, connection_observer: ConnectionObserver, client_observer: ClientObserver):
@ -34,6 +31,9 @@ class NotificationTerminalUI(QDialog):
self.worker_thread = None self.worker_thread = None
self.task_success = False self.task_success = False
self.connection_observer.subscribe("message",
lambda msg: self.add_notification("UPDATE", msg, "#00ff88"))
self.connection_observer.subscribe("connecting", self.connection_observer.subscribe("connecting",
lambda msg: self.add_notification("CONNECT", msg, "#00ff88")) lambda msg: self.add_notification("CONNECT", msg, "#00ff88"))