* Move visibility param from redux store to local state * use func for parsing location.search * Remove bad wrapper * we already have wrapper with NODE_ID on page and we shouldn't another one with the same id on page * move common part of markup to level up * Tinny refac of setSorting * add dummy types for pollyfils also, a bit rewrited way to resolve imports * Move sort flag to local store Because we don't need to share this param between diffrent parts of interface * Add action creators * move action to action creators * Remove unused functions * Merge in conditions in one * One way for export API methods * add default tags * Rewrited changing read only mode * removed unused function * set sort changes * always send sort from store * rollback if sort don't work * constanst * add typing * shorten export * remove double define of host
25 lines
760 B
TypeScript
25 lines
760 B
TypeScript
import { PostInfo } from '@app/common/types';
|
|
|
|
import { StoreAction } from '../index';
|
|
import { POST_INFO_SET, POST_INFO_SET_ACTION } from './types';
|
|
import { disableComments, enableComments } from '@app/common/api';
|
|
import { unsetCommentMode } from '../comments/actions';
|
|
|
|
export function setPostInfo(info: PostInfo) {
|
|
return {
|
|
type: POST_INFO_SET,
|
|
info,
|
|
} as POST_INFO_SET_ACTION;
|
|
}
|
|
|
|
/** set state of post: readonly or not */
|
|
export function setCommentsReadOnlyState(read_only: boolean): StoreAction<Promise<void>> {
|
|
return async (dispatch, getState) => {
|
|
const { info } = getState();
|
|
|
|
await (read_only ? disableComments() : enableComments());
|
|
dispatch(unsetCommentMode());
|
|
dispatch(setPostInfo({ ...info, read_only }));
|
|
};
|
|
}
|