Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add in-app and system notifications #540

Merged
merged 11 commits into from Aug 19, 2021

Conversation

oshorefueled
Copy link
Contributor

@oshorefueled oshorefueled commented Jul 26, 2021

This PR resolves #527

It implements and in-app notification (toast) which is used in displaying success or error messages to a user within the app in response to an action. It also implements a system notification which displays os specific system-wide applications. Some of the notifications displayed with the system notification could be new block notifications, receive transaction notifications, transaction confirmation notification e.t.c..

Calls to the CreateToast method used by pages in the page package are replaced with the Notify method created in this PR.

ui/notification/toast.go Outdated Show resolved Hide resolved
ui/notification/toast.go Outdated Show resolved Hide resolved
return layout.Dimensions{}
}

t.handleToastDisplay(gtx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should be done at the top of the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moving the handle function to the top of the Layout method would lead to a nil dereference error.

@@ -0,0 +1,25 @@
// Copyright (c) 2017, The dcrdata developers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package does not need its own logger.

func (s *SystemNotification) Notify(message string) {
err := beeep.Notify(title, message, s.iconPath)
if err != nil {
log.Info("could not initiate desktop notification, reason:", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error should be returned not logged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log avoids handling notification errors in the ui code. All that needs to be called is the Notify method, just like toast notifications.

ui/notification/utils.go Outdated Show resolved Hide resolved
@oshorefueled oshorefueled force-pushed the notifications branch 5 times, most recently from 3b77f60 to 308d602 Compare August 2, 2021 18:57
@Sirmorrison Sirmorrison added this to Review in progress in godcr board Aug 14, 2021
beansgum added a commit to beansgum/godcr that referenced this pull request Aug 17, 2021
An error that causes the app to crash occurs when multiple notification
listeners are added with the same key. This occurred because a notification
listener added previously in the app onResume was not removed in onStop
which can happen if the OS fails to call onStop. This error is avoided by
removing any notification listener added with the key before adding a new
notification listener.
- add NotifyError method
- add comments to Notify methods
- call NotifyError for error messages in layout code and Notify for success
  messages.
@Sirmorrison Sirmorrison moved this from Review in progress to Approved in godcr board Aug 18, 2021
Copy link
Contributor

@Sirmorrison Sirmorrison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and looks good.

@oshorefueled oshorefueled merged commit 8652943 into planetdecred:master Aug 19, 2021
godcr board automation moved this from Approved to Done Aug 19, 2021
song50119 pushed a commit to song50119/godcr that referenced this pull request Apr 24, 2022
- add toast notification implementation to notification page
- move toast layout code to toast.go
- add toast to load and common structs
- remove previous toast implementation

* implement system notification

* stack toast layout on modals layout

* add delay speeds to toast notification

- add NotifyError method
- add comments to Notify methods
- call NotifyError for error messages in layout code and Notify for success
  messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
godcr board
  
Done
Development

Successfully merging this pull request may close these issues.

Implement toasts notifications on pages in the page package
3 participants