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

Browser notifications #284

Merged
merged 10 commits into from Mar 28, 2020
Merged

Conversation

frankdekker
Copy link
Contributor

Added notification support to the Web Interface.

  • icon added to enable and request notification permissions
  • throttle added when notifications are enabled, to only send once every 2 seconds

As Chrome/Firefox require secure context to allow notifications, added https cli arguments
See docs/https.md for details.

@codecov-io
Copy link

Codecov Report

Merging #284 into master will decrease coverage by 0.87%.
The diff coverage is 46.66%.

@@            Coverage Diff             @@
##           master     #284      +/-   ##
==========================================
- Coverage   71.65%   70.77%   -0.88%     
==========================================
  Files           9        9              
  Lines         515      527      +12     
  Branches      107      110       +3     
==========================================
+ Hits          369      373       +4     
- Misses        146      154       +8

@matthijsthoolen
Copy link

@oktapodia and maybe also this one, we would like this feature :)

Copy link
Member

@djfarrelly djfarrelly left a comment

Choose a reason for hiding this comment

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

Hi @frankdekker, this looks like a great feature and it also works on localhost w/out https which should make it very useful for lots of people. I'd like to make a couple changes to how support is communicated to the user as well as disabling. if you have other thoughts on this, please share them!


app.controller('MainCtrl', [
'$scope', '$rootScope', '$http', 'Email', '$route', '$location', 'Favicon',
function ($scope, $rootScope, $http, Email, $route, $location, Favicon) {
$scope.items = []
$scope.configOpen = false
$scope.currentItemId = null
$scope.notificationsSupported = 'Notification' in window
Copy link
Member

Choose a reason for hiding this comment

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

I think we should give user feedback if it's supported also using isSecureContext.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, what kind of feedback are you thinking of?

Copy link
Member

Choose a reason for hiding this comment

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

I decided to add a title attribute on the Notifications toggle now. Also with the new toggle design, Notifications is now greyed out if the browser context does not support it:

Screen Shot 2020-03-30 at 9 18 57 AM

@@ -93,6 +108,27 @@ app.controller('MainCtrl', [
$scope.autoShow = !$scope.autoShow
}

$scope.enableNotifications = function () {
if (window.Notification && window.Notification.permission === 'granted') {
window.alert('To disable notifications, revoke the permissions in your browser.')
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this alert, can we instead set $scope.webNotifications = false? This context will of course be lost when the browser window is closed, but it might be a better workflow. Perhaps if this was coupled with some setting storage in localStorage that may provide the best experience.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, hadn't thought about that. So instead of revoking permissions, you just silence the notifications. Great idea. The silence setting has to be stored preferrably. I as user found it already annoying to toggle the "autoShow" each time.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the input - all settings will be persisted after #291 :)

@@ -76,9 +79,15 @@ module.exports = function (config) {
}

if (!config.disableWeb) {
const secure = {
Copy link
Member

Choose a reason for hiding this comment

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

I like this grouping of the options together. Makes me think that web.start()'s arguments should be refactored soon.

window.alert('Unable to enable web notifications. See console for more information')
})
if (!window.isSecureContext && window.console) {
console.info(
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather make this more obvious to the user, perhaps using window.alert or a title on the html element.

@@ -0,0 +1,32 @@
# HTTPS
By default MailDev will run on the http protocol. For Web Notification support you'll need
Copy link
Member

Choose a reason for hiding this comment

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

One can also use web notification support on localhost in most browsers. We should update this copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah. I wasn't aware localhost was the exception. Indeed useful to be added.


## Open maildev with https
```
https:\\192.168.1.103:1080
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
https:\\192.168.1.103:1080
https:\\192.168.1.103:1080
https://192.168.1.103:1080

@djfarrelly djfarrelly merged commit db8dfd7 into maildev:master Mar 28, 2020
@djfarrelly djfarrelly added this to the 2.0.0 milestone Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants