Cleanup syncOptions

This commit is contained in:
Nathan Bierema 2024-08-11 09:43:29 -04:00
parent fae02a6d27
commit a7f6dbc0a2
3 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,7 @@
import configureStore from './store/backgroundStore';
import openDevToolsWindow, { DevToolsPosition } from './openWindow';
import { createMenu, removeMenu } from './contextMenus';
import syncOptions from '../options/syncOptions';
import createSyncOptions from '../options/syncOptions';
// Expose the extension's store globally to access it from the windows
// via chrome.runtime.getBackgroundPage
@ -16,7 +16,7 @@ chrome.commands.onCommand.addListener((shortcut) => {
chrome.runtime.onInstalled.addListener(() => {
chrome.action.disable();
syncOptions().get((option) => {
createSyncOptions().get((option) => {
if (option.showContextMenus) createMenu();
});
});

View File

@ -11,7 +11,7 @@ import {
TOGGLE_PERSIST,
UPDATE_STATE,
} from '@redux-devtools/app';
import syncOptions, {
import createSyncOptions, {
Options,
OptionsMessage,
} from '../../options/syncOptions';
@ -420,6 +420,8 @@ function toAllTabs(msg: TabMessage) {
});
}
const syncOptions = createSyncOptions(toAllTabs);
function monitorInstances(shouldMonitor: boolean, id?: string) {
if (!id && isMonitored === shouldMonitor) return;
const action = {
@ -497,7 +499,7 @@ function messaging<S, A extends Action<string>>(
return;
}
if (request.type === 'GET_OPTIONS') {
syncOptionsToAllTabs.get((options) => {
syncOptions.get((options) => {
sendResponse!({ options });
});
return;
@ -664,8 +666,6 @@ chrome.notifications.onClicked.addListener((id) => {
openDevToolsWindow('devtools-right');
});
const syncOptionsToAllTabs = syncOptions(toAllTabs); // Expose to the options page
const api: Middleware<{}, BackgroundState, Dispatch<BackgroundAction>> =
(store) => (next) => (untypedAction) => {
const action = untypedAction as BackgroundAction;

View File

@ -154,7 +154,7 @@ export interface SyncOptions {
readonly subscribe: (callback: (options: Options) => void) => void;
}
export default function syncOptions(toAllTabs?: ToAllTabs): SyncOptions {
export default function createSyncOptions(toAllTabs?: ToAllTabs): SyncOptions {
if (toAllTabs && !options) get(() => {}); // Initialize
return {
save: save(toAllTabs),