Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
4029f431
Commit
4029f431
authored
Mar 18, 2021
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix linting
parent
ac6b4616
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
34 deletions
+30
-34
src/redux/comments.js
src/redux/comments.js
+0
-4
src/redux/project-comment-actions.js
src/redux/project-comment-actions.js
+30
-30
No files found.
src/redux/comments.js
View file @
4029f431
const
keyMirror
=
require
(
'
keymirror
'
);
const
eachLimit
=
require
(
'
async/eachLimit
'
);
const
mergeWith
=
require
(
'
lodash.mergewith
'
);
const
uniqBy
=
require
(
'
lodash.uniqby
'
);
const
api
=
require
(
'
../lib/api
'
);
const
log
=
require
(
'
../lib/log
'
);
const
COMMENT_LIMIT
=
20
;
module
.
exports
.
Status
=
keyMirror
({
...
...
src/redux/project-comment-actions.js
View file @
4029f431
...
...
@@ -19,6 +19,35 @@ const {
setRepliesRestored
}
=
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
=>
{
dispatch
(
setFetchStatus
(
'
comments
'
,
Status
.
FETCHING
));
api
({
...
...
@@ -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
=>
{
/* TODO fetching/fetched/error states updates for comment deleting */
api
({
...
...
@@ -170,4 +170,4 @@ module.exports = {
deleteComment
,
reportComment
,
restoreComment
};
\ No newline at end of file
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment