Skip to content

Commit

Permalink
refactor(vscode): make it regularly read vscode status from its comma…
Browse files Browse the repository at this point in the history
…nd line interface every second
  • Loading branch information
sassanh committed Sep 7, 2024
1 parent 6c13efc commit 61e3436
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 1 addition & 9 deletions ubo_app/services/050-vscode/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion ubo_app/services/050-vscode/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -227,14 +229,18 @@ 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),
category=SettingsCategory.REMOTE,
),
)

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__)
Expand Down
2 changes: 1 addition & 1 deletion ubo_app/services/050-vscode/ubo_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 61e3436

Please sign in to comment.