1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

showing comments left count

This commit is contained in:
Fedor Katurov 2020-04-09 13:48:26 +07:00
parent 911beea4ad
commit 319e66616c
9 changed files with 101 additions and 115 deletions

View file

@ -3,6 +3,7 @@ import { INode, IResultWithStatus, IComment } from '../types';
import { API } from '~/constants/api';
import { nodeUpdateTags, nodeLike, nodeStar, nodeLock, nodeLockComment } from './actions';
import { INodeState } from './reducer';
import { COMMENTS_DISPLAY } from './constants';
export const postNode = ({
access,
@ -95,14 +96,16 @@ export const postNodeComment = ({
export const getNodeComments = ({
id,
access,
order = 'ASC',
take = COMMENTS_DISPLAY,
skip = 0,
}: {
id: number;
access: string;
order: 'ASC' | 'DESC';
take?: number;
skip?: number;
}): Promise<IResultWithStatus<{ comments: Comment[] }>> =>
api
.get(API.NODE.COMMENT(id), configWithToken(access, { params: { order } }))
.get(API.NODE.COMMENT(id), configWithToken(access, { params: { take, skip } }))
.then(resultMiddleware)
.catch(errorMiddleware);

View file

@ -97,94 +97,6 @@ export const EMPTY_COMMENT: IComment = {
temp_ids: [],
is_private: false,
user: null,
/*
files: [
{
name: 'screenshot_2019-09-29_21-13-38_502253296-1572589001092.png',
path: 'uploads/2019/10/image/',
full_path:
'public/uploads/2019/10/image/screenshot_2019-09-29_21-13-38_502253296-1572589001092.png',
url:
'REMOTE_CURRENT://uploads/2019/10/image/screenshot_2019-09-29_21-13-38_502253296-1572589001092.png',
size: 994331,
type: 'image',
mime: 'image/png',
metadata: {
width: 1919,
height: 1079,
},
id: 8709,
},
{
name: 'screenshot_2019-09-29_19-05-41_148603009-1572589001080.png',
path: 'uploads/2019/10/image/',
full_path:
'public/uploads/2019/10/image/screenshot_2019-09-29_19-05-41_148603009-1572589001080.png',
url:
'REMOTE_CURRENT://uploads/2019/10/image/screenshot_2019-09-29_19-05-41_148603009-1572589001080.png',
size: 2145,
type: 'image',
mime: 'image/png',
metadata: {
width: 445,
height: 446,
},
id: 8708,
},
{
name: 'screenshot_2019-09-29_21-13-26_924738012-1572589001110.png',
path: 'uploads/2019/10/image/',
full_path:
'public/uploads/2019/10/image/screenshot_2019-09-29_21-13-26_924738012-1572589001110.png',
url:
'REMOTE_CURRENT://uploads/2019/10/image/screenshot_2019-09-29_21-13-26_924738012-1572589001110.png',
size: 881224,
type: 'image',
mime: 'image/png',
metadata: {
width: 1919,
height: 1079,
},
id: 8710,
},
{
name:
'Advent_Chamber_Orchestra_-_05_-_Dvorak_-_Serenade_for_Strings_Op22_in_E_Major_larghetto-1572597841834.mp3',
path: 'uploads/2019/10/audio/',
full_path:
'public/uploads/2019/10/audio/Advent_Chamber_Orchestra_-_05_-_Dvorak_-_Serenade_for_Strings_Op22_in_E_Major_larghetto-1572597841834.mp3',
url:
'REMOTE_CURRENT://uploads/2019/10/audio/Advent_Chamber_Orchestra_-_05_-_Dvorak_-_Serenade_for_Strings_Op22_in_E_Major_larghetto-1572597841834.mp3',
size: 11155009,
type: 'audio',
mime: 'audio/mp3',
metadata: {
duration: 343.3795918367347,
id3title: 'Dvorak - Serenade for Strings Op22 in E Major larghetto',
id3artist: 'Advent Chamber Orchestra',
},
id: 8714,
},
{
name: '182a0d234aef882a58f240c5c0812bb2cad9506a875ca4c7c07d8f9f077ebb00-1572597841829.mp3',
path: 'uploads/2019/10/audio/',
full_path:
'public/uploads/2019/10/audio/182a0d234aef882a58f240c5c0812bb2cad9506a875ca4c7c07d8f9f077ebb00-1572597841829.mp3',
url:
'REMOTE_CURRENT://uploads/2019/10/audio/182a0d234aef882a58f240c5c0812bb2cad9506a875ca4c7c07d8f9f077ebb00-1572597841829.mp3',
size: 6038673,
type: 'audio',
mime: 'audio/mp3',
metadata: {
duration: 251.58530612244897,
id3title: null,
id3artist: null,
},
id: 8713,
},
],
*/
};
export const NODE_EDITORS = {
@ -219,3 +131,5 @@ export const NODE_SETTINGS = {
MAX_FILES: 16,
MAX_IMAGE_ASPECT: 1.2,
};
export const COMMENTS_DISPLAY = 25;

View file

@ -12,6 +12,7 @@ export type INodeState = Readonly<{
similar: Partial<INode[]>;
};
comment_data: Record<number, IComment>;
comment_count: number;
current_cover_image: IFile;
error: string;
@ -35,6 +36,7 @@ const INITIAL_STATE: INodeState = {
...EMPTY_COMMENT,
},
},
comment_count: 0,
comments: [],
related: null,
current_cover_image: null,

View file

@ -2,7 +2,13 @@ import { takeLatest, call, put, select, delay, all } from 'redux-saga/effects';
import { push } from 'connected-react-router';
import omit from 'ramda/es/omit';
import { NODE_ACTIONS, EMPTY_NODE, EMPTY_COMMENT, NODE_EDITOR_DATA } from './constants';
import {
NODE_ACTIONS,
EMPTY_NODE,
EMPTY_COMMENT,
NODE_EDITOR_DATA,
COMMENTS_DISPLAY,
} from './constants';
import {
nodeSave,
nodeSetSaveErrors,
@ -132,19 +138,20 @@ function* onNodeLoad({ id, order = 'ASC' }: ReturnType<typeof nodeLoadNode>) {
const {
comments: {
data: { comments },
data: { comments, comment_count },
},
related: {
data: { related },
},
} = yield all({
comments: call(reqWrapper, getNodeComments, { id, order }),
comments: call(reqWrapper, getNodeComments, { id, take: COMMENTS_DISPLAY, skip: 0 }),
related: call(reqWrapper, getNodeRelated, { id }),
});
yield put(
nodeSet({
comments,
comment_count,
related,
is_loading_comments: false,
comment_data: { 0: { ...EMPTY_COMMENT } },