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
add in-app and system notifications #540
Conversation
c0ad484
to
e44b8a9
Compare
ui/notification/toast.go
Outdated
return layout.Dimensions{} | ||
} | ||
|
||
t.handleToastDisplay(gtx) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
ui/notification/log.go
Outdated
@@ -0,0 +1,25 @@ | |||
// Copyright (c) 2017, The dcrdata developers |
There was a problem hiding this comment.
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.
ui/notification/system.go
Outdated
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()) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
3b77f60
to
308d602
Compare
- add toast nofication implementation to notification page - move toast layout code to toast.go - add toast to load and common structs - remove previous toast implementation
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.
ba2fd5e
to
8cf655b
Compare
8cf655b
to
a106bc7
Compare
- add NotifyError method - add comments to Notify methods - call NotifyError for error messages in layout code and Notify for success messages.
9ba193e
to
8814abc
Compare
There was a problem hiding this 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.
- 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.
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.