Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 84dd77a

Browse files
committed
fix(comments): dup init in logic & dup display in avatarRows
1 parent d022140 commit 84dd77a

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

components/AvatarsRow/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const AvatarsRow = ({
4242
return <span />
4343
}
4444

45-
users = R.filter(validUser, users)
45+
users = R.filter(validUser, R.uniqBy(R.path('id'), users))
4646
const sortedUsers = reverse ? users : R.reverse(users)
4747

4848
return (

containers/Comments/logic.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const defaultArgs = {
3434

3535
export const loadComents = (args = {}) => {
3636
// log('loadComents passed in: ', args)
37+
if (store.loading || store.loadingFresh) return false
3738
args = R.mergeDeepRight(defaultArgs, args)
3839
args.id = store.viewingData.id
3940
args.userHasLogin = store.isLogin
@@ -123,7 +124,10 @@ export const createReplyComment = () => {
123124
})
124125
}
125126

126-
sr71$.mutate(S.replyComment, {
127+
if (store.replying) return false
128+
129+
store.markState({ replying: true })
130+
return sr71$.mutate(S.replyComment, {
127131
id: store.replyToComment.id,
128132
body: store.replyContent,
129133
community: store.curCommunity.raw,
@@ -308,6 +312,7 @@ const DataSolver = [
308312
action: () => {
309313
store.markState({
310314
showReplyBox: false,
315+
replying: false,
311316
replyToComment: null,
312317
})
313318
scrollIntoEle('lists-info')
@@ -402,9 +407,10 @@ export const useInit = (_store, ssr) => {
402407
useEffect(() => {
403408
// log('effect init')
404409
store = _store
405-
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
406-
407-
if (!ssr) loadComents({ filter: { sort: TYPE.DESC_INSERTED } })
410+
if (!sub$) {
411+
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
412+
if (!ssr) loadComents({ filter: { sort: TYPE.DESC_INSERTED } })
413+
}
408414

409415
return () => {
410416
// log('effect uninit')
@@ -417,22 +423,3 @@ export const useInit = (_store, ssr) => {
417423
}
418424
}, [_store, ssr])
419425
}
420-
421-
/*
422-
export const init = (_store, ssr = false) => {
423-
store = _store
424-
425-
if (sub$) return false
426-
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
427-
428-
if (!ssr) return loadComents({ filter: { sort: TYPE.DESC_INSERTED } })
429-
}
430-
431-
export const uninit = () => {
432-
if (store.loading || store.loadingFresh || !sub$) return false
433-
stopDraftTimmer()
434-
sr71$.stop()
435-
sub$.unsubscribe()
436-
sub$ = null
437-
}
438-
*/

containers/Comments/schema.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const pagedComments = gql`
3434
}
3535
`
3636
const createComment = gql`
37-
mutation(
37+
mutation createComment(
3838
$community: String!
3939
$thread: CmsThread
4040
$id: ID!
@@ -64,7 +64,7 @@ const updateComment = gql`
6464
`
6565

6666
const replyComment = gql`
67-
mutation(
67+
mutation replyComment(
6868
$community: String!
6969
$thread: CmsThread
7070
$id: ID!

0 commit comments

Comments
 (0)