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
cc663412
Commit
cc663412
authored
May 17, 2021
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait for session to be fetched before loading comments
parent
8984f2ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
src/redux/session.js
src/redux/session.js
+1
-0
src/views/studio/studio-comments.jsx
src/views/studio/studio-comments.jsx
+6
-3
No files found.
src/redux/session.js
View file @
cc663412
...
...
@@ -128,6 +128,7 @@ module.exports.selectToken = state => get(state, ['session', 'session', 'user',
module
.
exports
.
selectIsAdmin
=
state
=>
get
(
state
,
[
'
session
'
,
'
session
'
,
'
permissions
'
,
'
admin
'
],
false
);
module
.
exports
.
selectIsSocial
=
state
=>
get
(
state
,
[
'
session
'
,
'
session
'
,
'
permissions
'
,
'
social
'
],
false
);
module
.
exports
.
selectIsEducator
=
state
=>
get
(
state
,
[
'
session
'
,
'
session
'
,
'
permissions
'
,
'
educator
'
],
false
);
module
.
exports
.
selectHasFetchedSession
=
state
=>
state
.
session
.
status
===
module
.
exports
.
Status
.
FETCHED
;
// NB logged out user id as NaN so that it can never be used in equality testing since NaN !== NaN
module
.
exports
.
selectUserId
=
state
=>
get
(
state
,
[
'
session
'
,
'
session
'
,
'
user
'
,
'
id
'
],
NaN
);
src/views/studio/studio-comments.jsx
View file @
cc663412
...
...
@@ -9,7 +9,7 @@ import TopLevelComment from '../preview/comment/top-level-comment.jsx';
import
studioCommentActions
from
'
../../redux/studio-comment-actions.js
'
;
import
StudioCommentsAllowed
from
'
./studio-comments-allowed.jsx
'
;
import
{
selectIsAdmin
}
from
'
../../redux/session
'
;
import
{
selectIsAdmin
,
selectHasFetchedSession
}
from
'
../../redux/session
'
;
import
{
selectShowCommentComposer
,
selectCanDeleteComment
,
...
...
@@ -24,6 +24,7 @@ const StudioComments = ({
comments
,
commentsAllowed
,
isAdmin
,
hasFetchedSession
,
handleLoadMoreComments
,
handleNewComment
,
moreCommentsToLoad
,
...
...
@@ -42,8 +43,8 @@ const StudioComments = ({
handleLoadMoreReplies
})
=>
{
useEffect
(()
=>
{
if
(
comments
.
length
===
0
)
handleLoadMoreComments
();
},
[
comments
.
length
===
0
]);
if
(
comments
.
length
===
0
&&
hasFetchedSession
)
handleLoadMoreComments
();
},
[
comments
.
length
===
0
,
hasFetchedSession
]);
// The comments you see depend on your admin status
// so reset them if isAdmin changes.
...
...
@@ -108,6 +109,7 @@ StudioComments.propTypes = {
comments
:
PropTypes
.
arrayOf
(
PropTypes
.
shape
({})),
commentsAllowed
:
PropTypes
.
bool
,
isAdmin
:
PropTypes
.
bool
,
hasFetchedSession
:
PropTypes
.
bool
,
handleLoadMoreComments
:
PropTypes
.
func
,
handleNewComment
:
PropTypes
.
func
,
moreCommentsToLoad
:
PropTypes
.
bool
,
...
...
@@ -133,6 +135,7 @@ export {
export
default
connect
(
state
=>
({
comments
:
state
.
comments
.
comments
,
hasFetchedSession
:
selectHasFetchedSession
(
state
),
isAdmin
:
selectIsAdmin
(
state
),
moreCommentsToLoad
:
state
.
comments
.
moreCommentsToLoad
,
replies
:
state
.
comments
.
replies
,
...
...
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