From 58c3bbc080ef5f56bedc59959ea2a7f620f6ad79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Saquetim?= <1108771+megothss@users.noreply.github.com> Date: Fri, 2 Jun 2023 19:06:13 -0300 Subject: [PATCH] FIX: Prevent undefined on isSafari capabilities test (#21914) Added a null coalesce operator on the field `isSafari` on the capabilities service to prevent an error in case `pushNotifications` is `undefined` --- app/assets/javascripts/discourse/app/services/capabilities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/services/capabilities.js b/app/assets/javascripts/discourse/app/services/capabilities.js index 0fa772318b5..aca1f7c1cd7 100644 --- a/app/assets/javascripts/discourse/app/services/capabilities.js +++ b/app/assets/javascripts/discourse/app/services/capabilities.js @@ -29,7 +29,7 @@ export default class Capabilities extends Service { this.isChrome = !!window.chrome && !this.isOpera; this.isSafari = /Constructor/.test(window.HTMLElement) || - window.safari?.pushNotification.toString() === + window.safari?.pushNotification?.toString() === "[object SafariRemoteNotification]"; this.hasContactPicker =