Commit 4029f431 authored by Paul Kaplan's avatar Paul Kaplan

Fix linting

parent ac6b4616
const keyMirror = require('keymirror'); const keyMirror = require('keymirror');
const eachLimit = require('async/eachLimit');
const mergeWith = require('lodash.mergewith'); const mergeWith = require('lodash.mergewith');
const uniqBy = require('lodash.uniqby'); const uniqBy = require('lodash.uniqby');
const api = require('../lib/api');
const log = require('../lib/log');
const COMMENT_LIMIT = 20; const COMMENT_LIMIT = 20;
module.exports.Status = keyMirror({ module.exports.Status = keyMirror({
......
...@@ -19,6 +19,35 @@ const { ...@@ -19,6 +19,35 @@ const {
setRepliesRestored setRepliesRestored
} = require('../redux/comments.js'); } = require('../redux/comments.js');
const getReplies = (projectId, commentIds, offset, ownerUsername, isAdmin, token) => (dispatch => {
dispatch(setFetchStatus('replies', Status.FETCHING));
const fetchedReplies = {};
eachLimit(commentIds, 10, (parentId, callback) => {
api({
uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${projectId}/comments/${parentId}/replies`,
authentication: token ? token : null,
params: {offset: offset || 0, limit: COMMENT_LIMIT}
}, (err, body, res) => {
if (err) {
return callback(`Error fetching comment replies: ${err}`);
}
if (typeof body === 'undefined' || res.statusCode >= 400) { // NotFound
return callback('No comment reply information');
}
fetchedReplies[parentId] = body;
callback(null, body);
});
}, err => {
if (err) {
dispatch(setFetchStatus('replies', Status.ERROR));
dispatch(setError(err));
return;
}
dispatch(setFetchStatus('replies', Status.FETCHED));
dispatch(setReplies(fetchedReplies));
});
});
const getTopLevelComments = (id, offset, ownerUsername, isAdmin, token) => (dispatch => { const getTopLevelComments = (id, offset, ownerUsername, isAdmin, token) => (dispatch => {
dispatch(setFetchStatus('comments', Status.FETCHING)); dispatch(setFetchStatus('comments', Status.FETCHING));
api({ api({
...@@ -78,35 +107,6 @@ const getCommentById = (projectId, commentId, ownerUsername, isAdmin, token) => ...@@ -78,35 +107,6 @@ const getCommentById = (projectId, commentId, ownerUsername, isAdmin, token) =>
}); });
}); });
const getReplies = (projectId, commentIds, offset, ownerUsername, isAdmin, token) => (dispatch => {
dispatch(setFetchStatus('replies', Status.FETCHING));
const fetchedReplies = {};
eachLimit(commentIds, 10, (parentId, callback) => {
api({
uri: `${isAdmin ? '/admin' : `/users/${ownerUsername}`}/projects/${projectId}/comments/${parentId}/replies`,
authentication: token ? token : null,
params: {offset: offset || 0, limit: COMMENT_LIMIT}
}, (err, body, res) => {
if (err) {
return callback(`Error fetching comment replies: ${err}`);
}
if (typeof body === 'undefined' || res.statusCode >= 400) { // NotFound
return callback('No comment reply information');
}
fetchedReplies[parentId] = body;
callback(null, body);
});
}, err => {
if (err) {
dispatch(setFetchStatus('replies', Status.ERROR));
dispatch(setError(err));
return;
}
dispatch(setFetchStatus('replies', Status.FETCHED));
dispatch(setReplies(fetchedReplies));
});
});
const deleteComment = (projectId, commentId, topLevelCommentId, token) => (dispatch => { const deleteComment = (projectId, commentId, topLevelCommentId, token) => (dispatch => {
/* TODO fetching/fetched/error states updates for comment deleting */ /* TODO fetching/fetched/error states updates for comment deleting */
api({ api({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment