Skip to content

Commit

Permalink
Fix crash when installing web app on Linux and macOS (fixes #452)
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed Jan 22, 2024
1 parent f351a97 commit 7610e8b
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions extension/src/sites/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Tags from 'bootstrap5-tags/tags'
import * as DOMPurify from 'dompurify'

import {
EVENT_LOCALIZATION_READY,
obtainManifest,
obtainProfileList,
obtainSiteList,
Expand All @@ -18,6 +19,24 @@ import {
import { getMessage } from '../utils/i18n'
import { knownCategories } from './categories'

function displayProfileWarning (platform) {
if (platform.os === 'linux' || platform.os === 'mac' || platform.os === 'openbsd') {
const issueLink = document.getElementById('web-app-profile-warn-issue')
switch (platform.os) {
case 'linux':
case 'openbsd':
issueLink.href = 'https://github.com/filips123/PWAsForFirefox/issues/322'
issueLink.innerText = '#322'
break
case 'mac':
issueLink.href = 'https://github.com/filips123/PWAsForFirefox/issues/81'
issueLink.innerText = '#81'
}

document.getElementById('web-app-profile-warn-box').classList.remove('d-none')
}
}

async function initializeForm () {
const form = document.getElementById('web-app-form')
const submit = document.getElementById('web-app-submit')
Expand All @@ -33,23 +52,10 @@ async function initializeForm () {
element.tagsInstance = new Tags(element)
}

// Display profile warning on Linux, macOS and BSD
const platform = await browser.runtime.getPlatformInfo()
if (platform.os === 'linux' || platform.os === 'mac' || platform.os === 'openbsd') {
const issueLink = document.getElementById('web-app-profile-warn-issue')
switch (platform.os) {
case 'linux':
case 'openbsd':
issueLink.href = 'https://github.com/filips123/PWAsForFirefox/issues/322'
issueLink.innerText = '#322'
break
case 'mac':
issueLink.href = 'https://github.com/filips123/PWAsForFirefox/issues/81'
issueLink.innerText = '#81'
}

document.getElementById('web-app-profile-warn-box').classList.remove('d-none')
}
// Display profile warning on Linux, macOS and BSD
document.addEventListener(EVENT_LOCALIZATION_READY, displayProfileWarning.bind(null, platform))

// Obtain manifest and document URLs for the current site
let manifestUrl, documentUrl, pageInfo
Expand Down

0 comments on commit 7610e8b

Please sign in to comment.