diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ab41500..dd816821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ - fix(voice): remove "clear access key" item when access key is not set #97 - fix(voice): update pvorca to 2.1.0 as they suddenly yanked 1.4.0 in pypi #103 - refactor(vscode): flatten vscode menu items into its main menu #102 +- feat(vscode): show a notification with chime and led feedback when VSCode successfully + logs in #96 ## Version 0.14.0 diff --git a/ubo_app/services/050-vscode/reducer.py b/ubo_app/services/050-vscode/reducer.py index 55959946..683b6a8a 100644 --- a/ubo_app/services/050-vscode/reducer.py +++ b/ubo_app/services/050-vscode/reducer.py @@ -3,8 +3,20 @@ from dataclasses import replace -from redux import InitAction, InitializationActionError +from redux import ( + BaseEvent, + CompleteReducerResult, + InitAction, + InitializationActionError, +) +from ubo_gui.constants import SUCCESS_COLOR +from ubo_app.store.services.notifications import ( + Importance, + Notification, + NotificationDisplayType, + NotificationsAddAction, +) from ubo_app.store.services.vscode import ( VSCodeAction, VSCodeDoneDownloadingAction, @@ -14,7 +26,12 @@ ) -def reducer(state: VSCodeState | None, action: VSCodeAction) -> VSCodeState: +def reducer( + state: VSCodeState | None, + action: VSCodeAction, +) -> ( + CompleteReducerResult[VSCodeState, NotificationsAddAction, BaseEvent] | VSCodeState +): if state is None: if isinstance(action, InitAction): return VSCodeState() @@ -27,11 +44,32 @@ def reducer(state: VSCodeState | None, action: VSCodeAction) -> VSCodeState: return replace(state, is_downloading=False) if isinstance(action, VSCodeSetStatusAction): - return replace( + actions = [] + if ( + (not state.status or not state.status.is_running) + and action.status + and action.status.is_running + ): + actions.append( + NotificationsAddAction( + notification=Notification( + title='VSCode', + content='Service is running', + icon='󰨞', + importance=Importance.MEDIUM, + color=SUCCESS_COLOR, + display_type=NotificationDisplayType.FLASH, + ), + ), + ) + + state = replace( state, is_binary_installed=action.is_binary_installed, is_logged_in=action.is_logged_in, status=action.status, ) + return CompleteReducerResult(state=state, actions=actions) + return state