1
0
Fork 0

Try to detect incompatible web browsers

This commit is contained in:
Chocobozzz 2018-03-08 12:01:55 +01:00
parent 6a6d92b1ec
commit 73e09f2706
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 39 additions and 11 deletions

View 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()

View 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
}
}

View File

@ -34,6 +34,21 @@
</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>

View 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
})

View 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;
}