]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Try to detect incompatible web browsers
authorChocobozzz <me@florianbigard.com>
Thu, 8 Mar 2018 11:01:55 +0000 (12:01 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 8 Mar 2018 11:01:55 +0000 (12:01 +0100)
client/src/app/app.component.ts
client/src/app/videos/+video-watch/video-watch.component.ts
client/src/index.html
client/src/main.ts
client/src/sass/application.scss

index f95103365e73822af9a3903e18ed1b9a82caea48..5d8e8badf757bf6692384301d994d838a5c2fab7 100644 (file)
@@ -44,6 +44,8 @@ export class AppComponent implements OnInit {
   }
 
   ngOnInit () {
+    document.getElementById('incompatible-browser').className += 'browser-ok'
+
     const pathname = window.location.pathname
     if (!pathname || pathname === '/') {
       this.redirectService.redirectToHomepage()
index 5750c5fca2996c3509bee02e77dc2ef88058b438..7951e392703f909cdf1d61ce954179511e47c033 100644 (file)
@@ -49,8 +49,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   shortVideoDescription: string
   videoHTMLDescription = ''
   likesBarTooltipText = ''
+  hasAlreadyAcceptedPrivacyConcern = false
 
-  private hasAlreadyAcceptedPrivacyConcern = false
   private otherVideos: Video[] = []
   private paramsSub: Subscription
 
@@ -260,6 +260,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
       )
   }
 
+  acceptedPrivacyConcern () {
+    localStorage.setItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
+    this.hasAlreadyAcceptedPrivacyConcern = true
+  }
+
   private updateVideoDescription (description: string) {
     this.video.description = description
     this.setVideoDescriptionHTML()
@@ -470,9 +475,4 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     // Be sure the autoPlay is set to false
     return this.user.autoPlayVideo !== false
   }
-
-  private acceptedPrivacyConcern () {
-    localStorage.setItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
-    this.hasAlreadyAcceptedPrivacyConcern = true
-  }
 }
index a824a39e2b8b89a1cb41eb293ffa21687093d4da..cd9f76cf9ddb1685fed7d28daa9e4b6d20afb988 100644 (file)
       </p>
     </noscript>
 
+    <div id="incompatible-browser" class="alert alert-danger" style="display: none">
+      <p>We are sorry but it seems that PeerTube is not compatible with your web browser.</p>
+      <p>Please try with the latest version of <a href="https://www.mozilla.org" target="_blank">Mozilla Firefox</a>.</p>
+      <p>If you think this is a mistake, do not hesitate <a href="https://github.com/Chocobozzz/PeerTube/issues/new" target="_blank">to report it</a>.</p>
+    </div>
+
+    <script type="text/javascript">
+      window.onerror = function () {
+        var elem = document.getElementById('incompatible-browser')
+        if (elem.className.indexOf('browser-ok') === -1) {
+          elem.style.display = 'block'
+        }
+      }
+    </script>
+
     <my-app>
     </my-app>
 
index 4b18d163c446c09f13b4a485e93c1c1fd12f0e1f..e1a69e4a4b55a5d86ba5bd3fdb77da19c51ed49a 100644 (file)
@@ -20,11 +20,14 @@ const bootstrap = () => platformBrowserDynamic()
     //     .catch(err => console.error('Cannot register service worker.', err))
     // }
 
-    navigator.serviceWorker.getRegistrations().then(registrations => {
-      for (const registration of registrations) {
-        registration.unregister()
-      }
-    })
+    if (navigator.serviceWorker) {
+      navigator.serviceWorker.getRegistrations()
+        .then(registrations => {
+          for (const registration of registrations) {
+            registration.unregister()
+          }
+        })
+    }
 
     return bootstrapModule
   })
index 438990a4057f58bd5406e243e06157843831b961..f2d9f720126537e8466171cafea95cc20759a44b 100644 (file)
@@ -24,6 +24,14 @@ body {
   color: #000;
 }
 
+#incompatible-browser {
+  display: none;
+  text-align: center;
+  position: absolute;
+  width: 100%;
+  top: 45%;
+}
+
 strong {
   font-weight: $font-semibold;
 }