Compare commits

..

No commits in common. "5996a117b33f20b31002baf7544966e890d891c1" and "a0b39365a3bd8a731094666458ac7173fc463454" have entirely different histories.

7 changed files with 13 additions and 40 deletions

View file

@ -56,8 +56,3 @@ def navigate_to_singbox_setup() -> Result:
return Result(valid=False, error_type=ResultError.NAVIGATE_TO, navigate_to="networking_setup")
@register_action(ResultError.NODE_ERROR)
def down_location_edit_page():
print(f"going to the edit page and boolean_value as true, for the location being down.")
return Result(valid=False, data=True, error_type=ResultError.NAVIGATE_TO, navigate_to="editor")

View file

@ -349,15 +349,12 @@ def disconnect_active(ui_caller: Optional[Callable] = None) -> Result:
else:
return Result(valid=True)
def sync_now(ui_caller: Callable, force_all: bool = False):
if force_all:
logger.info("Performing sync with force all")
def sync_now(ui_caller: Callable):
take_action(
action=new_sync,
ui_caller=ui_caller,
client_observer=client_observer,
connection_observer=connection_observer,
force_all=force_all
connection_observer=connection_observer
)
def delete_profile_action(profile_id: int, ui_caller: Callable) -> Result:

View file

@ -16,14 +16,13 @@ def create_profile(potential_data: dict, ui_caller: Callable):
)
@type_checker
def edit_profile(profile_id: int, location_down: bool, potential_data: dict, ui_caller: Callable):
def edit_profile(profile_id: int, potential_data: dict, ui_caller: Callable):
"""Pass the data through the plumbing, to edit a profile."""
take_action(
action=update_profile,
ui_caller=ui_caller,
profile_id=profile_id,
new_choices=potential_data,
server_location_change=location_down
new_choices=potential_data
)
def get_all_profiles(ui_caller: Callable):

View file

@ -49,7 +49,7 @@ class Navigator(QObject):
return getattr(module, class_name)
def _instantiate(self, name, prepared=None, profile_id=None, location_down=None):
def _instantiate(self, name, prepared=None, profile_id=None):
cls = self.get_class(name)
# 1. Inspect the constructor's parameters
@ -70,10 +70,6 @@ class Navigator(QObject):
if "prepared" in params:
kwargs["prepared"] = prepared
# Only add location_down if the class accepts it
if location_down is not None and "location_down" in params:
kwargs["location_down"] = location_down
# 3. Instantiate using the filtered dictionary
return cls(**kwargs)
@ -82,7 +78,7 @@ class Navigator(QObject):
self.page_stack.addWidget(page)
self._instances[name] = page
def navigate(self, name, profile_id = None, location_down = None):
def navigate(self, name, profile_id = None):
page = self._instances.get(name)
if page is None:
@ -97,10 +93,6 @@ class Navigator(QObject):
logger.info(f"Navigator is setting profile_id data of {profile_id}")
page.profile_id = profile_id
if location_down is not None:
logger.info(f"Navigator is setting location_down data of {location_down}")
page.location_down = location_down
# Make it visible:
self.page_stack.setCurrentIndex(self.page_stack.indexOf(page))
return page

View file

@ -25,7 +25,7 @@ class PreEdit:
class RegistrationState:
def __init__(self, btn_path, profile_id: Optional[int] = None, location_down: Optional[bool] = False):
def __init__(self, btn_path, profile_id: Optional[int] = None):
self.btn_path = btn_path
self.all_options = {}
self.selections = {}
@ -36,7 +36,6 @@ class RegistrationState:
self.proceed = False
self.warnings_dict = {}
self.key_choices = []
self.location_down = location_down
# Maps a category to the function that validates its current selection.
self._filter_map = {
@ -342,8 +341,7 @@ class RegistrationState:
# 2. Map keys to their specific warning messages
WARNING_MESSAGES = {
"location": lambda: "If you change the location, it wipes the subscription, proceed?"
if not self.location_down
and not profile_can_respawn(self.profile_id).valid
if not profile_can_respawn(self.profile_id).valid
and profile_can_respawn(self.profile_id).error_type != ResultError.SUBSCRIPTION
else None,
"browser": lambda: "If you change the browser, it wipes the cookies/bookmarks, proceed?"

View file

@ -17,10 +17,9 @@ from typing import Optional
class EditPage(Page):
def __init__(self, page_stack, main_window, prepared=None, profile_id: Optional[int] = None, location_down: Optional[bool] = False):
def __init__(self, page_stack, main_window, prepared=None, profile_id: Optional[int] = None):
super().__init__("EditPage", page_stack, main_window)
self.profile_id = profile_id
self.location_down = location_down
# 1. Permanent Structure: Created once in init
self.content_area = QWidget()
@ -63,7 +62,7 @@ class EditPage(Page):
# 2. State Reset: Wipe old widgets and old state
self.clear_ui()
self.state = RegistrationState(btn_path=self.btn_path, profile_id=profile_id, location_down=self.location_down)
self.state = RegistrationState(btn_path=self.btn_path, profile_id=profile_id)
print("Created a new RegistrationState")
# 3. Create groups, passing the category string and the state object
@ -144,19 +143,18 @@ class EditPage(Page):
def proceed_with_edit(self, different_content):
print(f"different_content is {different_content} and self.location_down is {self.location_down}")
print(f"different_content is {different_content}")
edit_profile(
profile_id=self.profile_id,
potential_data=different_content,
location_down=self.location_down,
ui_caller=self.after_submission
)
self.created_display = False
def submit_edits(self):
print(f"submit_edits with self.location as {self.location_down}")
print("submit_edits")
# name
input_text = self.group_name.text_input.text()
if not input_text:

View file

@ -684,13 +684,7 @@ class MenuPage(Page):
def deal_with_errors(self, result: Result):
if result.error_type == ResultError.NAVIGATE_TO:
print(f"We are auto-navigating to page {result.navigate_to}")
if result.navigate_to == "editor" and result.data:
print("going to editor page with a different location")
profile_id = self.reverse_id
print(f"profile_id is {profile_id}")
self.custom_window.navigator.navigate(name="editor", profile_id=profile_id, location_down=result.data)
else:
self.custom_window.navigator.navigate(name=result.navigate_to)
self.custom_window.navigator.navigate(result.navigate_to)
elif result.error_type == ResultError.SUBSCRIPTION:
print("We are navigating to the subscription page")