Fixing terminal sync startup messages and completion

This commit is contained in:
SimplifiedPrivacy 2026-10-24 20:26:31 -04:00
parent fa50ea2e79
commit 54fd77085c

View file

@ -1,5 +1,7 @@
from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
from core.observers.Notifications import Notifications, EventType
from core.observers.ConnectionObserver import ConnectionObserver
from core.observers.ClientObserver import ClientObserver
from core.services.networking.api_requests.ApiResponseModel import ApiResponse, ErrorType
@ -31,23 +33,25 @@ class NotificationTerminalUI(QDialog):
self.worker_thread = None
self.task_success = False
self.connection_observer.subscribe("message",
lambda msg: self.add_notification("UPDATE", msg, "#00ff88"))
Notifications.subscribe(EventType.STATUS_UPDATE, self.add_notification_from_eventbus)
self.connection_observer.subscribe("connecting",
lambda msg: self.add_notification("CONNECT", msg, "#00ff88"))
# self.connection_observer.subscribe("message",
# lambda msg: self.add_notification("UPDATE", msg, "#00ff88"))
self.connection_observer.subscribe("tor_bootstrapping",
lambda msg: self.add_notification("BOOTSTRAP", msg, "#00d4ff"))
# self.connection_observer.subscribe("connecting",
# lambda msg: self.add_notification("CONNECT", msg, "#00ff88"))
self.connection_observer.subscribe("tor_bootstrap_progressing",
lambda msg: self.add_notification("PROGRESS", msg, "#ff0088"))
# self.connection_observer.subscribe("tor_bootstrapping",
# lambda msg: self.add_notification("BOOTSTRAP", msg, "#00d4ff"))
self.connection_observer.subscribe("tor_bootstrapped",
lambda msg: self.add_notification("SUCCESS", msg, "#00ff88"))
# self.connection_observer.subscribe("tor_bootstrap_progressing",
# lambda msg: self.add_notification("PROGRESS", msg, "#ff0088"))
self.connection_observer.subscribe("custom_message",
lambda msg: self.add_notification("INFO", msg, "#ffff00"))
# self.connection_observer.subscribe("tor_bootstrapped",
# lambda msg: self.add_notification("SUCCESS", msg, "#00ff88"))
# self.connection_observer.subscribe("custom_message",
# lambda msg: self.add_notification("INFO", msg, "#ffff00"))
# Subscribe to client_observer events
self.client_observer.subscribe("synchronizing",
@ -191,6 +195,12 @@ class NotificationTerminalUI(QDialog):
button_layout.addStretch()
layout.addLayout(button_layout)
def add_notification_from_eventbus(self, message: str):
"""Queue to main thread safely."""
self.mainthread(lambda: self._add_notification_impl(prefix="Connect/Sync", message=message, color="#00ff88"))()
def add_notification(self, prefix: str, message: str, color: str = "#00ff88"):
"""Queue to main thread safely."""
self.mainthread(lambda: self._add_notification_impl(prefix, message, color))()
@ -205,6 +215,11 @@ class NotificationTerminalUI(QDialog):
self.output_text.setTextCursor(cursor)
self.output_text.ensureCursorVisible()
if message == "Finshed sync.":
print("Close Event")
self.accept()
def set_status(self, text: str):
"""This runs on the main thread, safely."""
self.status_label.setText(text)