Files
leagues-tools/os-league-tools-master/src/store.js
sonderau ea8484fca7 Imagery imported for icons and items. Live updates working.
Hover tooltip working. Features.md added for better tracking.
2025-10-28 08:41:04 +08:00

57 lines
2.3 KiB
JavaScript

import { configureStore } from '@reduxjs/toolkit';
import throttle from 'lodash/throttle';
import { updateLocalStorage, LOCALSTORAGE_KEYS } from './client/localstorage-client';
import filterReducer, { loadState as loadFilterState } from './store/filters';
import settingsReducer, { loadState as loadSettingsState } from './store/settings/settings';
import tasksReducer, { loadState as loadTasksState } from './store/tasks/tasks';
import unlocksReducer, { loadState as loadUnlocksState } from './store/unlocks/unlocks';
import characterReducer, { loadState as loadCharacterState, selectActiveCharacter } from './store/user/character';
import accountReducer, { loadState as loadAccountState } from './store/user/account';
import calculatorsReducer, { loadState as loadCalculatorsState } from './store/calculators/calculators';
import groupReducer, { loadState as loadGroupState } from './store/group/groupState';
const reducer = {
filters: filterReducer,
settings: settingsReducer,
tasks: tasksReducer,
unlocks: unlocksReducer,
character: characterReducer,
account: accountReducer,
calculators: calculatorsReducer,
group: groupReducer,
};
const preloadedState = {
filters: loadFilterState(),
settings: loadSettingsState(),
tasks: loadTasksState(),
unlocks: loadUnlocksState(),
character: loadCharacterState(),
account: loadAccountState(),
calculators: loadCalculatorsState(),
group: loadGroupState(),
};
const store = configureStore({
reducer,
preloadedState,
});
store.subscribe(
throttle(() => {
updateLocalStorage(LOCALSTORAGE_KEYS.FILTER_STATE, store.getState().filters);
updateLocalStorage(LOCALSTORAGE_KEYS.SETTINGS, store.getState().settings);
updateLocalStorage(`${LOCALSTORAGE_KEYS.TASKS}_${selectActiveCharacter(store.getState())}`, store.getState().tasks);
updateLocalStorage(
`${LOCALSTORAGE_KEYS.UNLOCKS}_${selectActiveCharacter(store.getState())}`,
store.getState().unlocks
);
updateLocalStorage(LOCALSTORAGE_KEYS.CHARACTER, store.getState().character);
updateLocalStorage(LOCALSTORAGE_KEYS.ACCOUNT, store.getState().account);
updateLocalStorage(LOCALSTORAGE_KEYS.CALCULATORS, store.getState().calculators);
updateLocalStorage(LOCALSTORAGE_KEYS.GROUP, store.getState().group);
}, 200)
);
export default store;