diff --git a/CHANGELOG.md b/CHANGELOG.md index 9191bf9a..9c4c6f4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - feat(ci): add `ubo-pod-pi5` to the list of github runners for `test`, also use it for `dependencies` and `type-check` jobs - refactor(core): improve update-manager to be event driven - feat(core): add `UBO_ENABLED_SERVICES` to complement `UBO_DISABLED_SERVICES` in controlling which services should load +- refactor(vscode): make it regularly read vscode status from its command line interface every second ## Version 0.15.11 diff --git a/tests/integration/results/test_services/all_services_register/store-desktop-000.jsonc b/tests/integration/results/test_services/all_services_register/store-desktop-000.jsonc index d63fd55f..12845f42 100644 --- a/tests/integration/results/test_services/all_services_register/store-desktop-000.jsonc +++ b/tests/integration/results/test_services/all_services_register/store-desktop-000.jsonc @@ -1023,8 +1023,8 @@ "_type": "VSCodeState", "is_binary_installed": false, "is_downloading": false, - "is_logged_in": null, - "is_pending": true, + "is_logged_in": false, + "is_pending": false, "status": null }, "wifi": { diff --git a/tests/integration/results/test_services/all_services_register/store-rpi-000.jsonc b/tests/integration/results/test_services/all_services_register/store-rpi-000.jsonc index bcde50a3..19719b12 100644 --- a/tests/integration/results/test_services/all_services_register/store-rpi-000.jsonc +++ b/tests/integration/results/test_services/all_services_register/store-rpi-000.jsonc @@ -1093,8 +1093,8 @@ "_type": "VSCodeState", "is_binary_installed": false, "is_downloading": false, - "is_logged_in": null, - "is_pending": true, + "is_logged_in": false, + "is_pending": false, "status": null }, "wifi": { diff --git a/ubo_app/services/050-vscode/commands.py b/ubo_app/services/050-vscode/commands.py index 0fcdbebe..c4644a30 100644 --- a/ubo_app/services/050-vscode/commands.py +++ b/ubo_app/services/050-vscode/commands.py @@ -40,7 +40,7 @@ class TunnelServiceStatus(TypedDict): wait=1, options=DebounceOptions(leading=True, trailing=False, time_window=1), ) -async def _check_status() -> None: +async def check_status() -> None: is_binary_installed = CODE_BINARY_PATH.exists() status_data: TunnelServiceStatus | None = None is_logged_in = False @@ -128,14 +128,6 @@ async def _check_status() -> None: ) -async def check_status() -> None: - await _check_status() - await asyncio.sleep(1) - await _check_status() - await asyncio.sleep(4) - await _check_status() - - async def set_name() -> None: store.dispatch(VSCodeSetPendingAction()) try: diff --git a/ubo_app/services/050-vscode/setup.py b/ubo_app/services/050-vscode/setup.py index d091e06e..d86a7bc0 100644 --- a/ubo_app/services/050-vscode/setup.py +++ b/ubo_app/services/050-vscode/setup.py @@ -8,8 +8,10 @@ from _constants import CODE_BINARY_PATH, CODE_BINARY_URL, DOWNLOAD_PATH from commands import check_status, install_service, uninstall_service +from kivy.clock import Clock from kivy.lang.builder import Builder from login_page import LoginPage +from redux import FinishEvent from ubo_gui.constants import DANGER_COLOR from ubo_gui.menu.types import ActionItem, ApplicationItem, HeadedMenu from ubo_gui.page import PageWidget @@ -227,7 +229,7 @@ def generate_vscode_menu() -> Callable[[], HeadedMenu]: return vscode_menu -def init_service() -> None: +async def init_service() -> None: store.dispatch( RegisterSettingAppAction( menu_item=ActionItem(label='VSCode', icon='󰨞', action=generate_vscode_menu), @@ -235,6 +237,10 @@ def init_service() -> None: ), ) + clock_event = Clock.schedule_interval(lambda _: create_task(check_status()), 1) + store.subscribe_event(FinishEvent, clock_event.cancel) + await check_status() + Builder.load_file( pathlib.Path(__file__) diff --git a/ubo_app/services/050-vscode/ubo_handle.py b/ubo_app/services/050-vscode/ubo_handle.py index f0fd2f73..abf7c7bc 100644 --- a/ubo_app/services/050-vscode/ubo_handle.py +++ b/ubo_app/services/050-vscode/ubo_handle.py @@ -12,7 +12,7 @@ async def setup(service: Service) -> None: from setup import init_service service.register_reducer(reducer) - init_service() + await init_service() register(