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 const SCROLL_SYNC_ENABLED = 'cms.scroll-sync-enabled';
|
|
|
|
|
|
|
|
export const TOGGLE_SCROLL = 'TOGGLE_SCROLL';
|
|
|
|
export const SET_SCROLL = 'SET_SCROLL';
|
|
|
|
|
|
|
|
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>;
|