@nextcloud/notify_push
Advanced tools
+1
-0
@@ -9,2 +9,3 @@ declare global { | ||
| _notify_push_available: boolean; | ||
| _notify_push_error_count: number; | ||
| } | ||
@@ -11,0 +12,0 @@ } |
+21
-13
@@ -49,3 +49,3 @@ "use strict"; | ||
| function getSupportedTypes() { | ||
| var capabilities = capabilities_1.getCapabilities(); | ||
| var capabilities = (0, capabilities_1.getCapabilities)(); | ||
| if (capabilities.notify_push) { | ||
@@ -87,7 +87,9 @@ return capabilities.notify_push.type; | ||
| window._notify_push_available = false; | ||
| event_bus_1.subscribe('networkOffline', function () { | ||
| window._notify_push_error_count = 0; | ||
| (0, event_bus_1.subscribe)('networkOffline', function () { | ||
| window._notify_push_online = false; | ||
| window._notify_push_ws = null; | ||
| }); | ||
| event_bus_1.subscribe('networkOnline', function () { | ||
| (0, event_bus_1.subscribe)('networkOnline', function () { | ||
| window._notify_push_error_count = 0; | ||
| window._notify_push_online = true; | ||
@@ -108,3 +110,3 @@ setupSocket(); | ||
| window._notify_push_ws = true; | ||
| capabilities = capabilities_1.getCapabilities(); | ||
| capabilities = (0, capabilities_1.getCapabilities)(); | ||
| if (!capabilities.notify_push) { | ||
@@ -130,12 +132,17 @@ window._notify_push_available = false; | ||
| window._notify_push_ws.onmessage = function (message) { | ||
| var i = message.data.indexOf(' '); | ||
| var _a = i > 0 ? [message.data.slice(0, i), message.data.slice(i + 1)] : [message.data, null], event = _a[0], body = _a[1]; | ||
| if (body) { | ||
| body = JSON.parse(body); | ||
| if (message.data === "authenticated") { | ||
| window._notify_push_error_count = 0; | ||
| } | ||
| if (window._notify_push_listeners[event]) { | ||
| for (var _i = 0, _b = window._notify_push_listeners[event]; _i < _b.length; _i++) { | ||
| var cb = _b[_i]; | ||
| cb(event, body); | ||
| else { | ||
| var i = message.data.indexOf(' '); | ||
| var _a = i > 0 ? [message.data.slice(0, i), message.data.slice(i + 1)] : [message.data, null], event_1 = _a[0], body = _a[1]; | ||
| if (body) { | ||
| body = JSON.parse(body); | ||
| } | ||
| if (window._notify_push_listeners[event_1]) { | ||
| for (var _i = 0, _b = window._notify_push_listeners[event_1]; _i < _b.length; _i++) { | ||
| var cb = _b[_i]; | ||
| cb(event_1, body); | ||
| } | ||
| } | ||
| } | ||
@@ -145,2 +152,3 @@ }; | ||
| window._notify_push_ws = null; | ||
| window._notify_push_error_count += 1; | ||
| setTimeout(function () { | ||
@@ -150,3 +158,3 @@ if (window._notify_push_online) { | ||
| } | ||
| }, 1000); | ||
| }, 1000 * window._notify_push_error_count); | ||
| }; | ||
@@ -153,0 +161,0 @@ return [2 /*return*/, true]; |
+17
-9
@@ -11,2 +11,3 @@ import {getCapabilities} from '@nextcloud/capabilities'; | ||
| _notify_push_available: boolean, | ||
| _notify_push_error_count: number, | ||
| } | ||
@@ -60,2 +61,3 @@ } | ||
| window._notify_push_available = false; | ||
| window._notify_push_error_count = 0; | ||
@@ -67,2 +69,3 @@ subscribe('networkOffline', () => { | ||
| subscribe('networkOnline', () => { | ||
| window._notify_push_error_count = 0; | ||
| window._notify_push_online = true; | ||
@@ -114,11 +117,15 @@ setupSocket(); | ||
| window._notify_push_ws.onmessage = message => { | ||
| const i = message.data.indexOf(' '); | ||
| let [event, body] = i > 0 ? [message.data.slice(0, i), message.data.slice(i + 1)] : [message.data, null]; | ||
| if (body) { | ||
| body = JSON.parse(body); | ||
| } | ||
| if (message.data === "authenticated") { | ||
| window._notify_push_error_count = 0; | ||
| } else { | ||
| const i = message.data.indexOf(' '); | ||
| let [event, body] = i > 0 ? [message.data.slice(0, i), message.data.slice(i + 1)] : [message.data, null]; | ||
| if (body) { | ||
| body = JSON.parse(body); | ||
| } | ||
| if (window._notify_push_listeners[event]) { | ||
| for (let cb of window._notify_push_listeners[event]) { | ||
| cb(event, body); | ||
| if (window._notify_push_listeners[event]) { | ||
| for (let cb of window._notify_push_listeners[event]) { | ||
| cb(event, body); | ||
| } | ||
| } | ||
@@ -130,2 +137,3 @@ } | ||
| window._notify_push_ws = null; | ||
| window._notify_push_error_count += 1; | ||
@@ -136,3 +144,3 @@ setTimeout(() => { | ||
| } | ||
| }, 1000); | ||
| }, 1000 * window._notify_push_error_count); | ||
| } | ||
@@ -139,0 +147,0 @@ |
+1
-1
| { | ||
| "name": "@nextcloud/notify_push", | ||
| "version": "1.1.1", | ||
| "version": "1.1.2", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
217623
0.37%2841
0.6%