-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(comment): hide most of info in archived/banned comments
- Loading branch information
Showing
13 changed files
with
166 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
import type { GQLCommentResolvers } from 'definitions' | ||
|
||
import { COMMENT_STATE } from 'common/enums' | ||
|
||
const resolver: GQLCommentResolvers['author'] = ( | ||
{ authorId }, | ||
{ authorId, state }, | ||
_, | ||
{ dataSources: { userService } } | ||
) => userService.loadById(authorId) | ||
{ viewer, dataSources: { userService } } | ||
) => { | ||
const isActive = state === COMMENT_STATE.active | ||
const isCollapsed = state === COMMENT_STATE.collapsed | ||
const isAdmin = viewer.hasRole('admin') | ||
if (isActive || isCollapsed || isAdmin) { | ||
return userService.loadById(authorId) | ||
} else { | ||
return null | ||
} | ||
} | ||
|
||
export default resolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { GQLCommentResolvers } from 'definitions' | ||
|
||
import { COMMENT_STATE } from 'common/enums' | ||
|
||
const resolver: GQLCommentResolvers['createdAt'] = ( | ||
{ createdAt, state }, | ||
_, | ||
{ viewer } | ||
) => { | ||
const isActive = state === COMMENT_STATE.active | ||
const isCollapsed = state === COMMENT_STATE.collapsed | ||
const isAdmin = viewer.hasRole('admin') | ||
if (isActive || isCollapsed || isAdmin) { | ||
return createdAt | ||
} else { | ||
// invalid date | ||
return new Date(0) | ||
} | ||
} | ||
|
||
export default resolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
import type { GQLCommentResolvers } from 'definitions' | ||
|
||
const resolver: GQLCommentResolvers['downvotes'] = ( | ||
{ id }, | ||
_, | ||
{ dataSources: { commentService } } | ||
) => 0 | ||
const resolver: GQLCommentResolvers['downvotes'] = () => 0 | ||
|
||
export default resolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
import type { GQLCommentResolvers } from 'definitions' | ||
|
||
import { COMMENT_STATE } from 'common/enums' | ||
|
||
const resolver: GQLCommentResolvers['replyTo'] = ( | ||
{ replyTo }, | ||
{ replyTo, state }, | ||
_, | ||
{ dataSources: { commentService } } | ||
) => (replyTo ? commentService.loadById(replyTo) : null) | ||
{ viewer, dataSources: { commentService } } | ||
) => { | ||
const isActive = state === COMMENT_STATE.active | ||
const isCollapsed = state === COMMENT_STATE.collapsed | ||
const isAdmin = viewer.hasRole('admin') | ||
if (isActive || isCollapsed || isAdmin) { | ||
return replyTo ? commentService.loadById(replyTo) : null | ||
} else { | ||
return null | ||
} | ||
} | ||
|
||
export default resolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
import type { GQLCommentResolvers } from 'definitions' | ||
|
||
import { COMMENT_STATE } from 'common/enums' | ||
|
||
const resolver: GQLCommentResolvers['upvotes'] = ( | ||
{ id, upvotes }: any, | ||
{ id, state }, | ||
_, | ||
{ dataSources: { commentService } } | ||
) => parseInt(upvotes, 10) || commentService.countUpVote(id) | ||
{ viewer, dataSources: { commentService } } | ||
) => { | ||
const isActive = state === COMMENT_STATE.active | ||
const isCollapsed = state === COMMENT_STATE.collapsed | ||
const isAdmin = viewer.hasRole('admin') | ||
if (isActive || isCollapsed || isAdmin) { | ||
return commentService.countUpVote(id) | ||
} else { | ||
return 0 | ||
} | ||
} | ||
|
||
export default resolver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters