Factor toggling all redirects out to its own file.
This commit is contained in:
parent
2acb8d804b
commit
6bd5bccd6f
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue