diff --git a/app/scenes/Document/components/DataLoader.tsx b/app/scenes/Document/components/DataLoader.tsx index b18e04d30..348485576 100644 --- a/app/scenes/Document/components/DataLoader.tsx +++ b/app/scenes/Document/components/DataLoader.tsx @@ -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, }); } diff --git a/app/stores/CommentsStore.ts b/app/stores/CommentsStore.ts index 0054cf81c..537024e08 100644 --- a/app/stores/CommentsStore.ts +++ b/app/stores/CommentsStore.ts @@ -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 { } } - @action - fetchDocumentComments = async ( - documentId: string, - options?: PaginationParams | undefined - ): Promise => { - 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");