kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Don't persist filters to localStorage
rodzic
4c765990f6
commit
8ead53a2c9
|
@ -60,9 +60,6 @@ const ExploreFilter = () => {
|
|||
useEffect(
|
||||
() => {
|
||||
const value = formatFilters(filters);
|
||||
|
||||
localStorage.setItem('soapbox:explore:filters', JSON.stringify(filters));
|
||||
|
||||
debouncedSearch(value);
|
||||
|
||||
return () => {
|
||||
|
|
|
@ -195,7 +195,6 @@ const CreateFilter = () => {
|
|||
|
||||
const handleReset = () => {
|
||||
dispatch(resetFilters());
|
||||
localStorage.removeItem('soapbox:explore:filters');
|
||||
};
|
||||
|
||||
const handleClearValue = () => {
|
||||
|
|
18
src/store.ts
18
src/store.ts
|
@ -7,26 +7,8 @@ import appReducer from './reducers/index.ts';
|
|||
|
||||
import type { AnyAction } from 'redux';
|
||||
|
||||
const loadState = (pathname: string) => {
|
||||
try {
|
||||
if (pathname !== '/explore') return undefined;
|
||||
|
||||
const savedState = localStorage.getItem('soapbox:explore:filters');
|
||||
return savedState ? JSON.parse(savedState) : undefined;
|
||||
} catch (error) {
|
||||
console.error('Failed to load state:', error);
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const preloadedState = (() => {
|
||||
const storedFilter = loadState(window.location.pathname);
|
||||
return storedFilter ? { search_filter: storedFilter } : {};
|
||||
})();
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: appReducer,
|
||||
preloadedState,
|
||||
middleware: () => new Tuple(
|
||||
thunk,
|
||||
errorsMiddleware(),
|
||||
|
|
Ładowanie…
Reference in New Issue