Skip to content

Commit

Permalink
Make first use less overwhelming with browser permissions (#4760)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Gargron committed Sep 1, 2017
1 parent 1a0df58 commit ff7d02b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/javascript/mastodon/containers/mastodon.js
Expand Up @@ -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());
Expand Down

0 comments on commit ff7d02b

Please sign in to comment.