Skip to content

Commit

Permalink
feat(vscode): show a notification with chime and led feedback when VS…
Browse files Browse the repository at this point in the history
…Code successfully logs in #96
  • Loading branch information
sassanh committed May 10, 2024
1 parent a91e763 commit 8968acd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
in the service file so that user can easily add their custom services
- fix(voice): remove "clear access key" item when access key is not set #97
- 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

Expand Down
44 changes: 41 additions & 3 deletions ubo_app/services/050-vscode/reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand All @@ -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

0 comments on commit 8968acd

Please sign in to comment.