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

added option "notification_requires_interaction" #1306

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -7,6 +7,7 @@
- #1188 Feature request: drag and drop file to HTTP Upload
- #1268 Switch from SASS variables to CSS custom properties
- #1278 Replace the default avatar with a SVG version
- #1306 added option `notification_delay`

## 4.0.4 (2018-10-29)

Expand Down
10 changes: 9 additions & 1 deletion docs/source/configuration.rst
Expand Up @@ -1005,6 +1005,15 @@ notified of all messages received in a room.
You can also pass an array of room JIDs to this option, to only apply it to
certain rooms.

notification_delay
------------------

* Default: ``5000``

Desktop notifications will be shown for a time of ``notification_delay``
ms. Setting this to ``0`` will make the notification stay until dismissed by
the user (requires browser support).

notification_icon
-----------------

Expand All @@ -1013,7 +1022,6 @@ notification_icon
This option specifies which icon is shown in HTML5 notifications, as provided
by the ``src/converse-notification.js`` plugin.


oauth_providers
---------------

Expand Down
10 changes: 7 additions & 3 deletions src/converse-notification.js
Expand Up @@ -33,7 +33,8 @@ converse.plugins.add('converse-notification', {
// ^ a list of JIDs to ignore concerning chat state notifications
play_sounds: true,
sounds_path: 'sounds/',
notification_icon: 'logo/conversejs-filled.svg'
notification_icon: 'logo/conversejs-filled.svg',
notification_delay: 5000
});

_converse.isOnlyChatStateNotification = (msg) =>
Expand Down Expand Up @@ -180,9 +181,12 @@ converse.plugins.add('converse-notification', {
const n = new Notification(title, {
'body': body,
'lang': _converse.locale,
'icon': _converse.notification_icon
'icon': _converse.notification_icon,
'requireInteraction': !_converse.notification_delay
});
setTimeout(n.close.bind(n), 5000);
if (_converse.notification_delay) {
setTimeout(n.close.bind(n), _converse.notification_delay);
}
};

_converse.showChatStateNotification = function (contact) {
Expand Down