Duplicative method cleanup (#6431)

This commit is contained in:
Tom Moor
2024-01-25 20:02:17 -08:00
committed by GitHub
parent cab9a1ec96
commit e62c734c41
13 changed files with 87 additions and 122 deletions

View File

@@ -1,4 +1,3 @@
import filter from "lodash/filter";
import orderBy from "lodash/orderBy";
import { action, computed } from "mobx";
import Comment from "~/models/Comment";
@@ -18,8 +17,9 @@ export default class CommentsStore extends Store<Comment> {
* @returns Array of comments
*/
threadsInDocument(documentId: string): Comment[] {
return this.inDocument(documentId).filter(
(comment) => !comment.parentCommentId
return this.filter(
(comment: Comment) =>
comment.documentId === documentId && !comment.parentCommentId
);
}
@@ -30,26 +30,12 @@ export default class CommentsStore extends Store<Comment> {
* @returns Array of comments
*/
inThread(threadId: string): Comment[] {
return filter(
this.orderedData,
(comment) =>
return this.filter(
(comment: Comment) =>
comment.parentCommentId === threadId || comment.id === threadId
);
}
/**
* Returns a list of comments in a document.
*
* @param documentId ID of the document to get comments for
* @returns Array of comments
*/
inDocument(documentId: string): Comment[] {
return filter(
this.orderedData,
(comment) => comment.documentId === documentId
);
}
@action
setTyping({
commentId,