about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-09-01 16:07:08 +0200
committerGitHub <noreply@github.com>2017-09-01 16:07:08 +0200
commitff7d02b2360bea107519f923cf084cbdd7fbca07 (patch)
treeac4ad5c80a528787a1dfd4afc6ffe141bc89f942 /app
parent1a0df58878430d340381112deffcc4c6e68b2529 (diff)
Make first use less overwhelming with browser permissions (#4760)
- Ask for desktop notifications after 1 minute of use instead of
  instantly
- Ask for protocol handler permission after 5 minutes of use
  instead of instantly
Diffstat (limited to 'app')
-rw-r--r--app/javascript/mastodon/containers/mastodon.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/javascript/mastodon/containers/mastodon.js b/app/javascript/mastodon/containers/mastodon.js
index 47180c506..884fc161a 100644
--- a/app/javascript/mastodon/containers/mastodon.js
+++ b/app/javascript/mastodon/containers/mastodon.js
@@ -28,13 +28,16 @@ export default class Mastodon extends React.PureComponent {
     this.disconnect = store.dispatch(connectUserStream());
 
     // Desktop notifications
+    // Ask after 1 minute
     if (typeof window.Notification !== 'undefined' && Notification.permission === 'default') {
-      Notification.requestPermission();
+      window.setTimeout(() => Notification.requestPermission(), 60 * 1000);
     }
 
+    // Protocol handler
+    // Ask after 5 minutes
     if (typeof navigator.registerProtocolHandler !== 'undefined') {
       const handlerUrl = window.location.protocol + '//' + window.location.host + '/intent?uri=%s';
-      navigator.registerProtocolHandler('web+mastodon', handlerUrl, 'Mastodon');
+      window.setTimeout(() => navigator.registerProtocolHandler('web+mastodon', handlerUrl, 'Mastodon'), 5 * 60 * 1000);
     }
 
     store.dispatch(showOnboardingOnce());