]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Prevent player crash on safari
authorChocobozzz <me@florianbigard.com>
Fri, 28 Oct 2022 13:44:19 +0000 (15:44 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 28 Oct 2022 13:44:19 +0000 (15:44 +0200)
client/src/assets/player/peertube-player-manager.ts

index 533ee1bb8f8de2a11ddd8b192bc7ff0a2a176398..5db7a2e5562d3a8d4327063d6858b56893bc7999 100644 (file)
@@ -133,13 +133,23 @@ export class PeertubePlayerManager {
         offlineNotificationElem.classList.add('vjs-peertube-offline-notification')
         offlineNotificationElem.innerText = player.localize('You seem to be offline and the video may not work')
 
+        let offlineNotificationElemAdded = false
+
         const handleOnline = () => {
+          if (!offlineNotificationElemAdded) return
+
           player.el().removeChild(offlineNotificationElem)
+          offlineNotificationElemAdded = false
+
           logger.info('The browser is online')
         }
 
         const handleOffline = () => {
+          if (offlineNotificationElemAdded) return
+
           player.el().appendChild(offlineNotificationElem)
+          offlineNotificationElemAdded = true
+
           logger.info('The browser is offline')
         }