Factor toggling all redirects out to its own file.

This commit is contained in:
Bauke 2022-11-21 13:23:27 +01:00
parent 2acb8d804b
commit 6bd5bccd6f
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import browser from 'webextension-polyfill';
import {updateBadge} from '../utilities/badge.js';
import {toggleAllRedirects} from '../utilities/toggle-all-redirects.js';
type ContextMenu = browser.Menus.CreateCreatePropertiesType;
@ -48,9 +48,6 @@ export async function contextClicked(
}
if (id === 're-nav-toggle-redirects') {
const state = await browser.storage.local.get({redirectsEnabled: true});
const redirectsEnabled = !(state.redirectsEnabled as boolean);
await browser.storage.local.set({redirectsEnabled});
await updateBadge(redirectsEnabled);
await toggleAllRedirects();
}
}

View File

@ -0,0 +1,10 @@
import browser from 'webextension-polyfill';
import {updateBadge} from './badge.js';
export async function toggleAllRedirects() {
const state = await browser.storage.local.get({redirectsEnabled: true});
const redirectsEnabled = !(state.redirectsEnabled as boolean);
await browser.storage.local.set({redirectsEnabled});
await updateBadge(redirectsEnabled);
}