mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added highlight for new comments
This commit is contained in:
parent
5585d566fd
commit
277f0fea43
19 changed files with 158 additions and 94 deletions
|
@ -74,12 +74,6 @@ export const nodeSetRelated = (related: INodeState['related']) => ({
|
|||
type: NODE_ACTIONS.SET_RELATED,
|
||||
});
|
||||
|
||||
export const nodeSetCommentData = (id: number, comment: Partial<IComment>) => ({
|
||||
id,
|
||||
comment,
|
||||
type: NODE_ACTIONS.SET_COMMENT_DATA,
|
||||
});
|
||||
|
||||
export const nodeUpdateTags = (id: INode['id'], tags: string[]) => ({
|
||||
type: NODE_ACTIONS.UPDATE_TAGS,
|
||||
id,
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
ApiGetNodeRelatedRequest,
|
||||
ApiGetNodeRelatedResult,
|
||||
ApiGetNodeRequest,
|
||||
ApiGetNodeResult,
|
||||
ApiGetNodeResponse,
|
||||
ApiLockCommentRequest,
|
||||
ApiLockcommentResult,
|
||||
ApiLockNodeRequest,
|
||||
|
@ -69,13 +69,13 @@ export const getNodeDiff = ({
|
|||
.then(cleanResult);
|
||||
|
||||
export const apiGetNode = ({ id }: ApiGetNodeRequest, config?: AxiosRequestConfig) =>
|
||||
api.get<ApiGetNodeResult>(API.NODE.GET_NODE(id), config).then(cleanResult);
|
||||
api.get<ApiGetNodeResponse>(API.NODE.GET_NODE(id), config).then(cleanResult);
|
||||
|
||||
export const apiGetNodeWithCancel = ({ id }: ApiGetNodeRequest) => {
|
||||
const cancelToken = axios.CancelToken.source();
|
||||
return {
|
||||
request: api
|
||||
.get<ApiGetNodeResult>(API.NODE.GET_NODE(id), {
|
||||
.get<ApiGetNodeResponse>(API.NODE.GET_NODE(id), {
|
||||
cancelToken: cancelToken.token,
|
||||
})
|
||||
.then(cleanResult),
|
||||
|
|
|
@ -44,7 +44,6 @@ export const NODE_ACTIONS = {
|
|||
SET_LOADING_COMMENTS: `${prefix}SET_LOADING_COMMENTS`,
|
||||
SET_SENDING_COMMENT: `${prefix}SET_SENDING_COMMENT`,
|
||||
SET_CURRENT: `${prefix}SET_CURRENT`,
|
||||
SET_COMMENT_DATA: `${prefix}SET_COMMENT_DATA`,
|
||||
SET_EDITOR: `${prefix}SET_EDITOR`,
|
||||
|
||||
POST_COMMENT: `${prefix}POST_LOCAL_COMMENT`,
|
||||
|
|
|
@ -7,7 +7,6 @@ import {
|
|||
nodeSetLoadingComments,
|
||||
nodeSetSendingComment,
|
||||
nodeSetComments,
|
||||
nodeSetCommentData,
|
||||
nodeSetTags,
|
||||
nodeSetEditor,
|
||||
nodeSetCoverImage,
|
||||
|
@ -46,20 +45,6 @@ const setComments = (state: INodeState, { comments }: ReturnType<typeof nodeSetC
|
|||
const setRelated = (state: INodeState, { related }: ReturnType<typeof nodeSetRelated>) =>
|
||||
assocPath(['related'], related, state);
|
||||
|
||||
const setCommentData = (
|
||||
state: INodeState,
|
||||
{ id, comment }: ReturnType<typeof nodeSetCommentData>
|
||||
) => ({
|
||||
...state,
|
||||
comment_data: {
|
||||
...state.comment_data,
|
||||
[id]: {
|
||||
...(state.comment_data[id] || {}),
|
||||
...comment,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const setTags = (state: INodeState, { tags }: ReturnType<typeof nodeSetTags>) =>
|
||||
assocPath(['current', 'tags'], tags, state);
|
||||
|
||||
|
@ -80,7 +65,6 @@ export const NODE_HANDLERS = {
|
|||
[NODE_ACTIONS.SET_SENDING_COMMENT]: setSendingComment,
|
||||
[NODE_ACTIONS.SET_COMMENTS]: setComments,
|
||||
[NODE_ACTIONS.SET_RELATED]: setRelated,
|
||||
[NODE_ACTIONS.SET_COMMENT_DATA]: setCommentData,
|
||||
[NODE_ACTIONS.SET_TAGS]: setTags,
|
||||
[NODE_ACTIONS.SET_EDITOR]: setEditor,
|
||||
[NODE_ACTIONS.SET_COVER_IMAGE]: setCoverImage,
|
||||
|
|
|
@ -9,7 +9,7 @@ export type INodeState = Readonly<{
|
|||
current: INode;
|
||||
comments: IComment[];
|
||||
related: INodeRelated;
|
||||
comment_data: Record<number, IComment>;
|
||||
lastSeenCurrent?: string;
|
||||
comment_count: number;
|
||||
current_cover_image?: IFile;
|
||||
|
||||
|
@ -29,11 +29,6 @@ const INITIAL_STATE: INodeState = {
|
|||
files: [],
|
||||
},
|
||||
current: { ...EMPTY_NODE },
|
||||
comment_data: {
|
||||
0: {
|
||||
...EMPTY_COMMENT,
|
||||
},
|
||||
},
|
||||
comment_count: 0,
|
||||
comments: [],
|
||||
related: {
|
||||
|
|
|
@ -19,7 +19,6 @@ import {
|
|||
nodeLockComment,
|
||||
nodePostLocalComment,
|
||||
nodeSet,
|
||||
nodeSetCommentData,
|
||||
nodeSetComments,
|
||||
nodeSetCurrent,
|
||||
nodeSetEditor,
|
||||
|
@ -43,9 +42,9 @@ import {
|
|||
apiPostNodeLike,
|
||||
apiPostNodeTags,
|
||||
} from './api';
|
||||
import { flowSetNodes, flowSetUpdated } from '../flow/actions';
|
||||
import { flowSetNodes } from '../flow/actions';
|
||||
import { modalSetShown, modalShowDialog } from '../modal/actions';
|
||||
import { selectFlow, selectFlowNodes } from '../flow/selectors';
|
||||
import { selectFlowNodes } from '../flow/selectors';
|
||||
import { URLS } from '~/constants/urls';
|
||||
import { selectNode } from './selectors';
|
||||
import { INode, Unwrap } from '../types';
|
||||
|
@ -54,7 +53,6 @@ import { DIALOGS } from '~/redux/modal/constants';
|
|||
import { has } from 'ramda';
|
||||
import { selectLabListNodes } from '~/redux/lab/selectors';
|
||||
import { labSetList } from '~/redux/lab/actions';
|
||||
import { INodeRelated } from '~/redux/node/types';
|
||||
|
||||
export function* updateNodeEverywhere(node) {
|
||||
const {
|
||||
|
@ -119,7 +117,6 @@ function* onNodeGoto({ id, node_type }: ReturnType<typeof nodeGotoNode>) {
|
|||
if (node_type) yield put(nodeSetCurrent({ ...EMPTY_NODE, type: node_type }));
|
||||
|
||||
yield put(nodeLoadNode(id));
|
||||
yield put(nodeSetCommentData(0, { ...EMPTY_COMMENT }));
|
||||
yield put(nodeSetRelated({ albums: {}, similar: [] }));
|
||||
}
|
||||
|
||||
|
@ -188,9 +185,9 @@ function* onNodeLoad({ id }: ReturnType<typeof nodeLoadNode>) {
|
|||
yield put(nodeSetLoading(true));
|
||||
yield put(nodeSetLoadingComments(true));
|
||||
|
||||
const { node }: Unwrap<typeof apiGetNode> = yield call(apiGetNode, { id });
|
||||
const { node, last_seen }: Unwrap<typeof apiGetNode> = yield call(apiGetNode, { id });
|
||||
|
||||
yield put(nodeSetCurrent(node));
|
||||
yield put(nodeSet({ current: node, lastSeenCurrent: last_seen }));
|
||||
yield put(nodeSetLoading(false));
|
||||
} catch (error) {
|
||||
yield put(push(URLS.ERRORS.NOT_FOUND));
|
||||
|
|
|
@ -31,7 +31,7 @@ export type PostCellViewResult = unknown; // TODO: update it with actual type
|
|||
export type ApiGetNodeRequest = {
|
||||
id: string | number;
|
||||
};
|
||||
export type ApiGetNodeResult = { node: INode };
|
||||
export type ApiGetNodeResponse = { node: INode; last_seen?: string };
|
||||
|
||||
export type ApiGetNodeRelatedRequest = {
|
||||
id: INode['id'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue