From 79e198bb0050fdc0df8174d63209f718bcdfa0e2 Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Sun, 12 May 2024 05:00:37 +0400 Subject: [PATCH] fix(vscode): show a success notification when the login process is completed instead of when the service runs #96 --- CHANGELOG.md | 5 +++++ pyproject.toml | 2 +- ubo_app/services/050-vscode/reducer.py | 9 ++------- ubo_app/services/050-vscode/setup.py | 8 +++++--- ubo_app/store/services/vscode.py | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c2a6eb0..3075b196 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # ChangeLog +## Version 0.14.2 + +- fix(vscode): show a success notification when the login process is completed instead + of when the service runs #96 + ## Version 0.14.1 - fix(docker): handle the case when ip interfaces are not initialized yet diff --git a/pyproject.toml b/pyproject.toml index a71e8741..b4fc444f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ubo-app" -version = "0.14.1" +version = "0.14.2" description = "Ubo main app, running on device initialization. A platform for running other apps." authors = ["Sassan Haradji "] license = "Apache-2.0" diff --git a/ubo_app/services/050-vscode/reducer.py b/ubo_app/services/050-vscode/reducer.py index a0b30f08..6a56fe9d 100644 --- a/ubo_app/services/050-vscode/reducer.py +++ b/ubo_app/services/050-vscode/reducer.py @@ -49,17 +49,12 @@ def reducer( if isinstance(action, VSCodeSetStatusAction): actions = [] - if ( - state.status - and not state.status.is_running - and action.status - and action.status.is_running - ): + if state.is_logged_in is False and action.is_logged_in: actions.append( NotificationsAddAction( notification=Notification( title='VSCode', - content='Service is running', + content='Successful Login', icon='󰨞', importance=Importance.MEDIUM, color=SUCCESS_COLOR, diff --git a/ubo_app/services/050-vscode/setup.py b/ubo_app/services/050-vscode/setup.py index cd3cca76..1fc8e579 100644 --- a/ubo_app/services/050-vscode/setup.py +++ b/ubo_app/services/050-vscode/setup.py @@ -141,7 +141,7 @@ class VSCodeQRCodePage(PageWidget): return actions -def login_actions(*, is_logged_in: bool) -> list[ActionItem | ApplicationItem]: +def login_actions(*, is_logged_in: bool | None) -> list[ActionItem | ApplicationItem]: actions = [] if is_logged_in: actions.extend( @@ -153,7 +153,7 @@ def login_actions(*, is_logged_in: bool) -> list[ActionItem | ApplicationItem]: ), ], ) - else: + elif is_logged_in is False: actions.append( ApplicationItem( label='Login', @@ -208,7 +208,9 @@ def vscode_menu(state: VSCodeState) -> HeadedMenu: status = 'Downloading...' elif not state.is_binary_installed: status = 'Code CLI not installed' - elif not state.is_logged_in: + elif state.is_logged_in is None: + status = 'Checking status...' + elif state.is_logged_in is False: status = 'Needs authentication' else: status = 'Unknown status' diff --git a/ubo_app/store/services/vscode.py b/ubo_app/store/services/vscode.py index 76796937..9a6b4f59 100644 --- a/ubo_app/store/services/vscode.py +++ b/ubo_app/store/services/vscode.py @@ -33,5 +33,5 @@ class VSCodeState(Immutable): is_pending: bool = True is_downloading: bool = False is_binary_installed: bool = False - is_logged_in: bool = False + is_logged_in: bool | None = None status: VSCodeStatus | None = None