restrict "share" to mobile, fixes #1505

Co-authored-by: timvisee <tim@visee.me>
This commit is contained in:
Danny Coates 2020-07-31 08:36:27 -07:00 committed by timvisee
parent 189f4cfb9b
commit 3631bc8f39
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172
2 changed files with 9 additions and 3 deletions

View File

@ -77,6 +77,7 @@ async function polyfillStreams() {
export default async function getCapabilities() {
const browser = browserName();
const isMobile = /mobi|android/i.test(navigator.userAgent);
const serviceWorker = 'serviceWorker' in navigator && browser !== 'edge';
let crypto = await checkCrypto();
const nativeStreams = checkStreams();
@ -91,14 +92,15 @@ export default async function getCapabilities() {
account = false;
}
const share =
typeof navigator.share === 'function' && locale().startsWith('en'); // en until strings merge
isMobile &&
typeof navigator.share === 'function' &&
locale().startsWith('en'); // en until strings merge
const standalone =
window.matchMedia('(display-mode: standalone)').matches ||
navigator.standalone;
const mobileFirefox =
browser === 'firefox' && /mobile/i.test(navigator.userAgent);
const mobileFirefox = browser === 'firefox' && isMobile;
return {
account,

View File

@ -142,12 +142,16 @@ function openLinksInNewTab(links, should = true) {
function browserName() {
try {
// order of these matters
if (/firefox/i.test(navigator.userAgent)) {
return 'firefox';
}
if (/edge/i.test(navigator.userAgent)) {
return 'edge';
}
if (/edg/i.test(navigator.userAgent)) {
return 'edgium';
}
if (/trident/i.test(navigator.userAgent)) {
return 'ie';
}