Add socket to panelStore

This commit is contained in:
Nathan Bierema 2024-08-13 21:33:22 -04:00
parent 20b575a0b1
commit 26f38527eb
3 changed files with 17 additions and 27 deletions

View File

@ -6,6 +6,7 @@ import { Persistor } from 'redux-persist';
import { import {
REMOVE_INSTANCE, REMOVE_INSTANCE,
StoreAction, StoreAction,
StoreState,
UPDATE_STATE, UPDATE_STATE,
} from '@redux-devtools/app'; } from '@redux-devtools/app';
import App from '../app/App'; import App from '../app/App';
@ -18,7 +19,6 @@ import {
SplitUpdateStateRequest, SplitUpdateStateRequest,
UpdateStateRequest, UpdateStateRequest,
} from '../background/store/apiMiddleware'; } from '../background/store/apiMiddleware';
import type { StoreStateWithoutSocket } from './store/panelReducer';
import { PersistGate } from 'redux-persist/integration/react'; import { PersistGate } from 'redux-persist/integration/react';
const position = location.hash; const position = location.hash;
@ -31,7 +31,7 @@ const messageStyle: CSSProperties = {
let rendered: boolean | undefined; let rendered: boolean | undefined;
let currentRoot: Root | undefined; let currentRoot: Root | undefined;
let store: Store<StoreStateWithoutSocket, StoreAction> | undefined; let store: Store<StoreState, StoreAction> | undefined;
let persistor: Persistor | undefined; let persistor: Persistor | undefined;
let bgConnection: chrome.runtime.Port; let bgConnection: chrome.runtime.Port;
let naTimeout: NodeJS.Timeout; let naTimeout: NodeJS.Timeout;

View File

@ -1,45 +1,29 @@
import { combineReducers, Reducer } from 'redux'; import { combineReducers, Reducer } from 'redux';
import { import {
connection, connection,
ConnectionState,
instances, instances,
InstancesState,
monitor, monitor,
MonitorState,
notification, notification,
NotificationState,
reports, reports,
ReportsState,
section, section,
SectionState, socket,
StateTreeSettings,
stateTreeSettings, stateTreeSettings,
StoreAction, StoreAction,
StoreState,
theme, theme,
ThemeState,
} from '@redux-devtools/app'; } from '@redux-devtools/app';
export interface StoreStateWithoutSocket {
readonly section: SectionState;
readonly theme: ThemeState;
readonly connection: ConnectionState;
readonly monitor: MonitorState;
readonly instances: InstancesState;
readonly reports: ReportsState;
readonly notification: NotificationState;
readonly stateTreeSettings: StateTreeSettings;
}
const rootReducer: Reducer< const rootReducer: Reducer<
StoreStateWithoutSocket, StoreState,
StoreAction, StoreAction,
Partial<StoreStateWithoutSocket> Partial<StoreState>
> = combineReducers({ > = combineReducers({
instances, instances,
monitor, monitor,
reports, reports,
notification, notification,
section, section,
socket,
theme, theme,
connection, connection,
stateTreeSettings, stateTreeSettings,

View File

@ -1,9 +1,13 @@
import { createStore, applyMiddleware, Reducer, Store } from 'redux'; import { createStore, applyMiddleware, Reducer, Store } from 'redux';
import localForage from 'localforage'; import localForage from 'localforage';
import { persistReducer, persistStore } from 'redux-persist'; import { persistReducer, persistStore } from 'redux-persist';
import { exportStateMiddleware, StoreAction } from '@redux-devtools/app'; import {
exportStateMiddleware,
StoreAction,
StoreState,
} from '@redux-devtools/app';
import panelDispatcher from './panelSyncMiddleware'; import panelDispatcher from './panelSyncMiddleware';
import rootReducer, { StoreStateWithoutSocket } from './panelReducer'; import rootReducer from './panelReducer';
const persistConfig = { const persistConfig = {
key: 'redux-devtools', key: 'redux-devtools',
@ -11,8 +15,10 @@ const persistConfig = {
storage: localForage, storage: localForage,
}; };
const persistedReducer: Reducer<StoreStateWithoutSocket, StoreAction> = const persistedReducer: Reducer<StoreState, StoreAction> = persistReducer(
persistReducer(persistConfig, rootReducer) as any; persistConfig,
rootReducer,
) as any;
export default function configureStore( export default function configureStore(
position: string, position: string,