diff --git a/misc/open_pieces_command.py b/misc/open_pieces_command.py index f93d557..92b181a 100644 --- a/misc/open_pieces_command.py +++ b/misc/open_pieces_command.py @@ -7,15 +7,20 @@ def run(self): sublime.set_timeout_async(self.run_async) @staticmethod - def run_async(): + def run_async() -> bool: if PiecesSettings.api_client.is_pieces_running(): - return sublime.status_message("PiecesOS is already running") + sublime.status_message("PiecesOS is already running") + return False view = sublime.active_window().active_view() view.set_status("OPEN_STATUS","Opening PiecesOS") if view else None if PiecesSettings.api_client.open_pieces_os(): view.erase_status("OPEN_STATUS") if view else None sublime.status_message("PiecesOS launched successfully") sublime.run_command("pieces_reload") - else: + return True + else: view.erase_status("OPEN_STATUS") if view else None - sublime.status_message("Unable to launch PiecesOS") \ No newline at end of file + sublime.status_message("Unable to launch PiecesOS") + if sublime.ok_cancel_dialog("PiecesOS could not be launched. Would you like to install it?"): + sublime.active_window().run_command("pieces_install_pieces_os") + return False \ No newline at end of file diff --git a/misc/reload_command.py b/misc/reload_command.py index 0c6d630..44e0e21 100644 --- a/misc/reload_command.py +++ b/misc/reload_command.py @@ -13,6 +13,7 @@ def run(self): def reload_async(self): if PiecesSettings.api_client.is_pieces_running(): try: + PiecesSettings.api_client._startup() # Running the startup command PiecesSettings.on_settings_change(all = True) sublime.status_message(f"Reloading [completed]") except Exception as e: diff --git a/startup_utils.py b/startup_utils.py index 8f6ab23..a4f037c 100644 --- a/startup_utils.py +++ b/startup_utils.py @@ -1,6 +1,7 @@ from ._pieces_lib.pieces_os_client.wrapper.version_compatibility import UpdateEnum, VersionChecker from ._pieces_lib.pieces_os_client.wrapper.websockets.health_ws import HealthWS from .settings import PiecesSettings +from .misc import PiecesOpenPiecesCommand import sublime from functools import wraps @@ -71,9 +72,14 @@ def run_async(): if r == sublime.DIALOG_NO: return sublime.run_command("pieces_support",args={"support":"https://docs.pieces.app/support"}) elif r == sublime.DIALOG_YES: - return sublime.run_command("pieces_open_pieces") + return sublime.set_timeout_async(lambda:open_pieces_async(func=func,*args,**kwargs)) print("Make sure PiecesOS is running") return wrapper return decorator +def open_pieces_async(func, *args, **kwargs): + running = PiecesOpenPiecesCommand.run_async() + if running: + func(*args, **kwargs) +