Skip to content

Commit

Permalink
extension: Change from switch/toggle to proper boolean for tab reload
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhjacobs committed Jul 17, 2024
1 parent 95ac802 commit ecc3cc4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions web/packages/extension/src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ async function onAdded(permissions: chrome.permissions.Permissions) {
permissions.origins.length >= 1 &&
permissions.origins[0] !== "<all_urls>"
) {
const { permissionsSwitch } = await utils.getOptions();
utils.storage.sync.set({
["permissionsSwitch"]: !permissionsSwitch,
await utils.storage.sync.set({
["showReloadButton"]: true,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion web/packages/extension/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface Options extends BaseLoadOptions {
ruffleEnable: boolean;
ignoreOptout: boolean;
autostart: boolean;
permissionsSwitch: boolean;
showReloadButton: boolean;
}

interface OptionElement<T> {
Expand Down
3 changes: 3 additions & 0 deletions web/packages/extension/src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ function isXMLDocument(): boolean {
}

(async () => {
await utils.storage.sync.set({
["showReloadButton"]: false,
});
const options = await utils.getOptions();
const explicitOptions = await utils.getExplicitOptions();

Expand Down
5 changes: 3 additions & 2 deletions web/packages/extension/src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ function optionsChanged() {
return;
}

const isDifferent = !deepEqual(savedOptions, tabOptions);
reloadButton.disabled = !isDifferent;
const showReloadButton = tabOptions.showReloadButton;
const notDifferent = deepEqual(savedOptions, tabOptions);
reloadButton.disabled = notDifferent && !showReloadButton;
}

async function displayTabStatus() {
Expand Down
2 changes: 1 addition & 1 deletion web/packages/extension/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const DEFAULT_OPTIONS: Required<Options> = {
ruffleEnable: true,
ignoreOptout: false,
autostart: false,
permissionsSwitch: false,
showReloadButton: false,
};

export let i18n: typeof browser.i18n | typeof chrome.i18n;
Expand Down

0 comments on commit ecc3cc4

Please sign in to comment.