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
b3795c94
Unverified
Commit
b3795c94
authored
Jun 23, 2021
by
Paul Kaplan
Committed by
GitHub
Jun 23, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5630 from paulkaplan/reduce-reply-requests
Only request replies if reply_count > 0
parents
b5a68924
2e976e03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
src/redux/project-comment-actions.js
src/redux/project-comment-actions.js
+7
-3
src/redux/studio-comment-actions.js
src/redux/studio-comment-actions.js
+7
-2
No files found.
src/redux/project-comment-actions.js
View file @
b3795c94
...
@@ -69,8 +69,10 @@ const getTopLevelComments = (id, offset, ownerUsername, isAdmin, token) => (disp
...
@@ -69,8 +69,10 @@ const getTopLevelComments = (id, offset, ownerUsername, isAdmin, token) => (disp
}
}
dispatch
(
setFetchStatus
(
'
comments
'
,
Status
.
FETCHED
));
dispatch
(
setFetchStatus
(
'
comments
'
,
Status
.
FETCHED
));
dispatch
(
setComments
(
body
));
dispatch
(
setComments
(
body
));
dispatch
(
getReplies
(
id
,
body
.
map
(
comment
=>
comment
.
id
),
0
,
ownerUsername
,
isAdmin
,
token
));
const
commentsWithReplies
=
body
.
filter
(
comment
=>
comment
.
reply_count
>
0
);
if
(
commentsWithReplies
.
length
>
0
)
{
dispatch
(
getReplies
(
id
,
commentsWithReplies
.
map
(
comment
=>
comment
.
id
),
0
,
ownerUsername
,
isAdmin
,
token
));
}
// If we loaded a full page of comments, assume there are more to load.
// If we loaded a full page of comments, assume there are more to load.
// This will be wrong (1 / COMMENT_LIMIT) of the time, but does not require
// This will be wrong (1 / COMMENT_LIMIT) of the time, but does not require
// any more server query complexity, so seems worth it. In the case of a project with
// any more server query complexity, so seems worth it. In the case of a project with
...
@@ -105,7 +107,9 @@ const getCommentById = (projectId, commentId, ownerUsername, isAdmin, token) =>
...
@@ -105,7 +107,9 @@ const getCommentById = (projectId, commentId, ownerUsername, isAdmin, token) =>
// If the comment is not a reply, show it as top level and load replies
// If the comment is not a reply, show it as top level and load replies
dispatch
(
setFetchStatus
(
'
comments
'
,
Status
.
FETCHED
));
dispatch
(
setFetchStatus
(
'
comments
'
,
Status
.
FETCHED
));
dispatch
(
setComments
([
body
]));
dispatch
(
setComments
([
body
]));
dispatch
(
getReplies
(
projectId
,
[
body
.
id
],
0
,
ownerUsername
,
isAdmin
,
token
));
if
(
body
.
reply_count
>
0
)
{
dispatch
(
getReplies
(
projectId
,
[
body
.
id
],
0
,
ownerUsername
,
isAdmin
,
token
));
}
});
});
});
});
...
...
src/redux/studio-comment-actions.js
View file @
b3795c94
...
@@ -90,7 +90,10 @@ const getTopLevelComments = () => ((dispatch, getState) => {
...
@@ -90,7 +90,10 @@ const getTopLevelComments = () => ((dispatch, getState) => {
}
}
dispatch
(
setFetchStatus
(
'
comments
'
,
Status
.
FETCHED
));
dispatch
(
setFetchStatus
(
'
comments
'
,
Status
.
FETCHED
));
dispatch
(
setComments
(
body
));
dispatch
(
setComments
(
body
));
dispatch
(
getReplies
(
body
.
map
(
comment
=>
comment
.
id
),
0
));
const
commentsWithReplies
=
body
.
filter
(
comment
=>
comment
.
reply_count
>
0
);
if
(
commentsWithReplies
.
length
>
0
)
{
dispatch
(
getReplies
(
commentsWithReplies
.
map
(
comment
=>
comment
.
id
),
0
));
}
// If we loaded a full page of comments, assume there are more to load.
// If we loaded a full page of comments, assume there are more to load.
// This will be wrong (1 / COMMENT_LIMIT) of the time, but does not require
// This will be wrong (1 / COMMENT_LIMIT) of the time, but does not require
...
@@ -130,7 +133,9 @@ const getCommentById = commentId => ((dispatch, getState) => {
...
@@ -130,7 +133,9 @@ const getCommentById = commentId => ((dispatch, getState) => {
// If the comment is not a reply, show it as top level and load replies
// If the comment is not a reply, show it as top level and load replies
dispatch
(
setFetchStatus
(
'
comments
'
,
Status
.
FETCHED
));
dispatch
(
setFetchStatus
(
'
comments
'
,
Status
.
FETCHED
));
dispatch
(
setComments
([
body
]));
dispatch
(
setComments
([
body
]));
dispatch
(
getReplies
(
body
.
id
,
0
));
if
(
body
.
reply_count
>
0
)
{
dispatch
(
getReplies
(
body
.
id
,
0
));
}
});
});
});
});
...
...
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