forked from Support/sp-hydra-veil-gui
Fixing terminal sync startup messages and completion
This commit is contained in:
parent
fa50ea2e79
commit
54fd77085c
1 changed files with 27 additions and 12 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
|
from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
|
||||||
|
|
||||||
|
from core.observers.Notifications import Notifications, EventType
|
||||||
|
|
||||||
from core.observers.ConnectionObserver import ConnectionObserver
|
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
|
||||||
|
|
@ -31,23 +33,25 @@ class NotificationTerminalUI(QDialog):
|
||||||
self.worker_thread = None
|
self.worker_thread = None
|
||||||
self.task_success = False
|
self.task_success = False
|
||||||
|
|
||||||
self.connection_observer.subscribe("message",
|
Notifications.subscribe(EventType.STATUS_UPDATE, self.add_notification_from_eventbus)
|
||||||
lambda msg: self.add_notification("UPDATE", msg, "#00ff88"))
|
|
||||||
|
|
||||||
self.connection_observer.subscribe("connecting",
|
# self.connection_observer.subscribe("message",
|
||||||
lambda msg: self.add_notification("CONNECT", msg, "#00ff88"))
|
# lambda msg: self.add_notification("UPDATE", msg, "#00ff88"))
|
||||||
|
|
||||||
self.connection_observer.subscribe("tor_bootstrapping",
|
# self.connection_observer.subscribe("connecting",
|
||||||
lambda msg: self.add_notification("BOOTSTRAP", msg, "#00d4ff"))
|
# lambda msg: self.add_notification("CONNECT", msg, "#00ff88"))
|
||||||
|
|
||||||
self.connection_observer.subscribe("tor_bootstrap_progressing",
|
# self.connection_observer.subscribe("tor_bootstrapping",
|
||||||
lambda msg: self.add_notification("PROGRESS", msg, "#ff0088"))
|
# lambda msg: self.add_notification("BOOTSTRAP", msg, "#00d4ff"))
|
||||||
|
|
||||||
self.connection_observer.subscribe("tor_bootstrapped",
|
# self.connection_observer.subscribe("tor_bootstrap_progressing",
|
||||||
lambda msg: self.add_notification("SUCCESS", msg, "#00ff88"))
|
# lambda msg: self.add_notification("PROGRESS", msg, "#ff0088"))
|
||||||
|
|
||||||
self.connection_observer.subscribe("custom_message",
|
# self.connection_observer.subscribe("tor_bootstrapped",
|
||||||
lambda msg: self.add_notification("INFO", msg, "#ffff00"))
|
# 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
|
# Subscribe to client_observer events
|
||||||
self.client_observer.subscribe("synchronizing",
|
self.client_observer.subscribe("synchronizing",
|
||||||
|
|
@ -191,6 +195,12 @@ class NotificationTerminalUI(QDialog):
|
||||||
button_layout.addStretch()
|
button_layout.addStretch()
|
||||||
layout.addLayout(button_layout)
|
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"):
|
def add_notification(self, prefix: str, message: str, color: str = "#00ff88"):
|
||||||
"""Queue to main thread safely."""
|
"""Queue to main thread safely."""
|
||||||
self.mainthread(lambda: self._add_notification_impl(prefix, message, color))()
|
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.setTextCursor(cursor)
|
||||||
self.output_text.ensureCursorVisible()
|
self.output_text.ensureCursorVisible()
|
||||||
|
|
||||||
|
if message == "Finshed sync.":
|
||||||
|
print("Close Event")
|
||||||
|
self.accept()
|
||||||
|
|
||||||
|
|
||||||
def set_status(self, text: str):
|
def set_status(self, text: str):
|
||||||
"""This runs on the main thread, safely."""
|
"""This runs on the main thread, safely."""
|
||||||
self.status_label.setText(text)
|
self.status_label.setText(text)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue