Skip to content

Commit

Permalink
fix(notifications): notifications aren't dismissed when the back butt…
Browse files Browse the repository at this point in the history
…on is pressed - closes #104
  • Loading branch information
sassanh committed May 13, 2024
1 parent e00885c commit b043268
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
menu when it is running
- fix(vscode): set a timeout for vscode commands - closes #101
- feat(docker): dedicated menu for logging out of registries
- fix(notifications): notifications aren't dismissed when the back button is pressed
- closes #104

## Version 0.14.1

Expand Down
29 changes: 14 additions & 15 deletions ubo_app/menu_app/menu_notification_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,24 @@ def display_notification( # noqa: C901
event: NotificationsDisplayEvent,
) -> None:
def run_notification_action(action: NotificationActionItem) -> None:
result = action.action()
if action.dismiss_notification:
dismiss()
return action.action()
else:
close()
return result

notification = event.notification

@mainthread
def close(_: object = None) -> None:
unsubscribe()
notification_application.unbind(on_close=close)
dispatch(CloseApplicationEvent(application=notification_application))

def dismiss(_: object = None) -> None:
notification_application.unbind(on_close=dismiss)
dispatch(
CloseApplicationEvent(application=notification_application),
NotificationsClearAction(notification=notification),
)
close()
dispatch(NotificationsClearAction(notification=notification))

items = []

Expand Down Expand Up @@ -116,20 +121,14 @@ def open_info() -> None:
dispatch(OpenApplicationEvent(application=notification_application))

if notification.display_type is NotificationDisplayType.FLASH:
Clock.schedule_once(
lambda _: dispatch(
CloseApplicationEvent(application=notification_application),
),
notification.flash_time,
)
Clock.schedule_once(close, notification.flash_time)

notification_application.bind(on_close=dismiss)
notification_application.bind(on_close=close)

@mainthread
def clear_notification(event: NotificationsClearEvent) -> None:
if event.notification == notification:
dispatch(CloseApplicationEvent(application=notification_application))
unsubscribe()
close()
if notification.on_close:
notification.on_close()

Expand Down
6 changes: 3 additions & 3 deletions ubo_app/services/030-wifi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def show_onboarding_notification() -> None:
dismiss_notification=True,
),
],
extra_information="""Press middle button to add WiFi network with \
{QR|K Y UW AA R} code.\nIf you dismiss this, you can always add WiFi network through \
Settings → Network → WiFi""",
extra_information="""Press middle button to add {WiFi|W AY F AY} \
network with {QR|K Y UW AA R} code.\nIf you dismiss this, you can always add \
{WiFi|W AY F AY} network through Settings → Network → {WiFi|W AY F AY}""",
color=INFO_COLOR,
),
),
Expand Down

0 comments on commit b043268

Please sign in to comment.