Commit b4fead3b authored by Thomas Greiner's avatar Thomas Greiner

Fixed #41 - Use requireInteraction notification flag if supported

parent 2efeeda7
Pipeline #76557548 failed with stages
......@@ -20,6 +20,7 @@
"use strict";
const {startIconAnimation, stopIconAnimation} = require("./icon");
const info = require("info");
const {Utils} = require("./utils");
const {Prefs} = require("./prefs");
const {Notification: NotificationStorage} =
......@@ -222,10 +223,20 @@ function showNotification(notification)
message,
buttons: buttons.map(button => ({title: button.title})),
// We use the highest priority to prevent the notification
// from closing automatically.
// from closing automatically, for browsers that don't support the
// requireInteraction flag.
priority: 2
};
// As of August 2019, only Chrome supports this flag and, since Firefox
// throws on unsupported options (tested with version 69), we need to
// explicitly set it only for supported browsers.
if (info.platform == "chromium" &&
parseInt(info.platformVersion, 10) >= 50)
{
notificationOptions.requireInteraction = true;
}
// Firefox and Opera don't support buttons. Firefox throws synchronously,
// while Opera gives an asynchronous error. Wrapping the promise like
// this, turns the synchronous error on Firefox into a promise rejection.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment