Run `tsc`
authorOlaf Braun <info@braun-development.de>
Mon, 13 May 2024 13:22:41 +0000 (15:22 +0200)
committerOlaf Braun <info@braun-development.de>
Mon, 13 May 2024 13:22:41 +0000 (15:22 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Notification/Handler.js

index b27d38c5c370c70fe31b78e926aa29d5d0eac16d..0e88d73245602bbd83c3e674f0a276fb5cc0deb2 100644 (file)
@@ -7,7 +7,7 @@
  * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @woltlabExcludeBundle tiny
  */
-define(["require", "exports", "tslib", "../Ajax", "../Core", "../Event/Handler", "WoltLabSuite/Core/Ui/User/Menu/Manager"], function (require, exports, tslib_1, Ajax, Core, EventHandler, Manager_1) {
+define(["require", "exports", "tslib", "../Ajax", "../Core", "../Event/Handler", "./ServiceWorker", "WoltLabSuite/Core/Ui/User/Menu/Manager"], function (require, exports, tslib_1, Ajax, Core, EventHandler, ServiceWorker_1, Manager_1) {
     "use strict";
     Object.defineProperty(exports, "__esModule", { value: true });
     exports.poll = exports.enableNotifications = exports.setup = void 0;
@@ -35,6 +35,14 @@ define(["require", "exports", "tslib", "../Ajax", "../Core", "../Event/Handler",
             if ("Notification" in window && Notification.permission === "granted") {
                 this.allowNotification = true;
             }
+            if ((0, ServiceWorker_1.serviceWorkerSupported)()) {
+                window.navigator.serviceWorker.addEventListener("message", (event) => {
+                    const payload = event.data;
+                    if (payload.time > this.lastRequestTimestamp) {
+                        this.lastRequestTimestamp = payload.time;
+                    }
+                });
+            }
         }
         enableNotifications() {
             this.allowNotification = true;