forked from Support/sp-hydra-veil-gui
UI gets state from the Repo in Cache, instead of JSON disk calls in a loop
This commit is contained in:
parent
17c6a8e258
commit
f7d792745a
3 changed files with 19 additions and 6 deletions
|
|
@ -107,8 +107,6 @@ def emergency_sync():
|
||||||
# BEGIN PROGRAM
|
# BEGIN PROGRAM
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# ASSETS FOLDER
|
# ASSETS FOLDER
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ from PyQt6 import QtGui
|
||||||
from PyQt6.QtCore import Qt, QTimer, QEvent
|
from PyQt6.QtCore import Qt, QTimer, QEvent
|
||||||
|
|
||||||
from core.Constants import Constants
|
from core.Constants import Constants
|
||||||
|
from core.infrastructure.global_state_coordinator import evaluate_state_on_startup
|
||||||
from core.infrastructure.service_registry import ServiceLocator
|
from core.infrastructure.service_registry import ServiceLocator
|
||||||
from core.controllers.ConfigurationController import ConfigurationController
|
from core.controllers.ConfigurationController import ConfigurationController
|
||||||
from core.controllers.ProfileController import ProfileController
|
from core.controllers.ProfileController import ProfileController
|
||||||
|
|
@ -909,6 +910,10 @@ class CustomWindow(QMainWindow):
|
||||||
|
|
||||||
|
|
||||||
def start_ui(force_sync):
|
def start_ui(force_sync):
|
||||||
|
worked = evaluate_state_on_startup()
|
||||||
|
if worked.valid:
|
||||||
|
core_logger.info("State evaluated.")
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
calculate_max_screensize(app)
|
calculate_max_screensize(app)
|
||||||
window = CustomWindow(force_sync=force_sync)
|
window = CustomWindow(force_sync=force_sync)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
from core.infrastructure.global_state import ProfileStateRepository
|
||||||
from core.controllers.ProfileController import ProfileController
|
from core.controllers.ProfileController import ProfileController
|
||||||
from core.controllers.SystemStateController import SystemStateController
|
from core.controllers.SystemStateController import SystemStateController
|
||||||
from core.models.system.SystemProfile import SystemProfile
|
from core.models.system.SystemProfile import SystemProfile
|
||||||
|
|
@ -21,7 +22,16 @@ def _system_state_profile_id():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def is_profile_enabled_for_gui(profile):
|
|
||||||
if isinstance(profile, SystemProfile) and _connection_code(profile) in SINGBOX_PROTOCOLS:
|
|
||||||
return _system_state_profile_id() == int(profile.id)
|
def is_profile_enabled_for_gui(profile) -> bool:
|
||||||
return ProfileController.is_enabled(profile)
|
"""Checks Profile State Against in-memory Repo"""
|
||||||
|
is_enabled = ProfileStateRepository().is_profile_active(profile.id)
|
||||||
|
print(f"profile id: {profile.id} | Enabled: {is_enabled}")
|
||||||
|
return is_enabled
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# if isinstance(profile, SystemProfile) and _connection_code(profile) in SINGBOX_PROTOCOLS:
|
||||||
|
# return _system_state_profile_id() == int(profile.id)
|
||||||
|
# return ProfileController.is_enabled(profile)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue