Skip to content

Commit

Permalink
Automatically set popup to contain options on iOS (#6592)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed May 4, 2023
1 parent 2c84aa8 commit b3e7358
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 40 deletions.
70 changes: 35 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@
"ts-extras": "^0.11.0",
"twas": "^2.1.3",
"webext-base-css": "^1.4.3",
"webext-detect-page": "^4.0.1",
"webext-domain-permission-toggle": "^4.0.0-0",
"webext-detect-page": "^4.1.0",
"webext-domain-permission-toggle": "^4.0.1",
"webext-dynamic-content-scripts": "^9.2.0",
"webext-options-sync-per-domain": "^4.0.0-0",
"webext-options-sync-per-domain": "^4.0.0",
"webext-storage-cache": "^6.0.0-2",
"webextension-polyfill": "^0.10.0",
"zip-text-nodes": "^1.0.0"
Expand Down
7 changes: 6 additions & 1 deletion source/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ import {isSafari} from 'webext-detect-page';
import {objectKeys} from 'ts-extras';
import addDomainPermissionToggle from 'webext-domain-permission-toggle';

import optionsStorage from './options-storage';
import optionsStorage, {isBrowserActionAPopup} from './options-storage';
import {getRghIssueUrl} from './helpers/rgh-issue-link';
import isDevelopmentVersion from './helpers/is-development-version';

// GHE support
addDomainPermissionToggle();

// No "Button link" support in iOS Safari
if (isBrowserActionAPopup) {
void browser.browserAction.setPopup({popup: 'options.html'});
}

const messageHandlers = {
openUrls(urls: string[], {tab}: browser.runtime.MessageSender) {
for (const [i, url] of urls.entries()) {
Expand Down
3 changes: 3 additions & 0 deletions source/options-storage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {isMobileSafari} from 'webext-detect-page';
import OptionsSyncPerDomain from 'webext-options-sync-per-domain';

import {importedFeatures} from '../readme.md';

export type RGHOptions = typeof defaults;

export const isBrowserActionAPopup = isMobileSafari();

// eslint-disable-next-line prefer-object-spread -- TypeScript doesn't merge the definitions so `...` is not equivalent.
const defaults = Object.assign({
actionUrl: '',
Expand Down
7 changes: 6 additions & 1 deletion source/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import clearCacheHandler from './helpers/clear-cache-handler';
import {getLocalHotfixes} from './helpers/hotfix';
import {createRghIssueLink} from './helpers/rgh-issue-link';
import {importedFeatures, featuresMeta} from '../readme.md';
import {perDomainOptions} from './options-storage';
import {isBrowserActionAPopup, perDomainOptions} from './options-storage';

type Status = {
error?: true;
Expand Down Expand Up @@ -289,6 +289,11 @@ function addEventListeners(): void {
window.open(event.delegateTarget.href);
}
});

// Hide non-applicable "Button link" section
if (isBrowserActionAPopup) {
select('#action')!.hidden = true;
}
}

async function init(): Promise<void> {
Expand Down

0 comments on commit b3e7358

Please sign in to comment.