30 lines
733 B
TypeScript
Raw Normal View History

import { SCROLL_SYNC_ENABLED, SET_SCROLL, TOGGLE_SCROLL } from '../constants';
2022-09-20 09:14:34 -04:00
import type { AnyAction } from 'redux';
import type { ThunkDispatch } from 'redux-thunk';
2022-10-20 11:57:30 -04:00
import type { RootState } from '../store';
2022-09-20 09:14:34 -04:00
export function togglingScroll() {
return {
type: TOGGLE_SCROLL,
} as const;
}
export function loadScroll() {
return {
type: SET_SCROLL,
payload: localStorage.getItem(SCROLL_SYNC_ENABLED) !== 'false',
} as const;
}
export function toggleScroll() {
2022-10-20 11:57:30 -04:00
return async (
dispatch: ThunkDispatch<RootState, undefined, AnyAction>,
_getState: () => RootState,
) => {
2022-09-20 09:14:34 -04:00
return dispatch(togglingScroll());
};
}
export type ScrollAction = ReturnType<typeof togglingScroll | typeof loadScroll>;