chore: Remove unused fetchDocumentComments method

This commit is contained in:
Tom Moor
2023-12-29 09:15:16 -05:00
parent 01c806d6ea
commit 8d74028f93
2 changed files with 3 additions and 30 deletions

View File

@@ -185,7 +185,8 @@ function DataLoader({ match, children }: Props) {
// when viewing a public share link
if (can.read) {
if (team.getPreference(TeamPreference.Commenting)) {
void comments.fetchDocumentComments(document.id, {
void comments.fetchPage({
documentId: document.id,
limit: 100,
});
}

View File

@@ -1,11 +1,7 @@
import invariant from "invariant";
import filter from "lodash/filter";
import orderBy from "lodash/orderBy";
import { action, runInAction, computed } from "mobx";
import { action, computed } from "mobx";
import Comment from "~/models/Comment";
import Document from "~/models/Document";
import { PaginationParams } from "~/types";
import { client } from "~/utils/ApiClient";
import RootStore from "./RootStore";
import Store, { RPCAction } from "./base/Store";
@@ -75,30 +71,6 @@ export default class CommentsStore extends Store<Comment> {
}
}
@action
fetchDocumentComments = async (
documentId: string,
options?: PaginationParams | undefined
): Promise<Document[]> => {
this.isFetching = true;
try {
const res = await client.post(`/comments.list`, {
documentId,
...options,
});
invariant(res?.data, "Comment list not available");
runInAction("CommentsStore#fetchDocumentComments", () => {
res.data.forEach(this.add);
this.addPolicies(res.policies);
});
return res.data;
} finally {
this.isFetching = false;
}
};
@computed
get orderedData(): Comment[] {
return orderBy(Array.from(this.data.values()), "createdAt", "asc");