yuken 3 лет назад
Родитель
Сommit
fce040f269
2 измененных файлов с 17 добавлено и 17 удалено
  1. 14 2
      packages/app/src/interfaces/comment.ts
  2. 3 15
      packages/app/src/stores/comment.tsx

+ 14 - 2
packages/app/src/interfaces/comment.ts

@@ -1,8 +1,8 @@
 import { Nullable, Ref } from './common';
+import { HasObjectId } from './has-object-id';
 import { IPage } from './page';
-import { IUser } from './user';
 import { IRevision } from './revision';
-import { HasObjectId } from './has-object-id';
+import { IUser } from './user';
 
 export type IComment = {
   comment: string;
@@ -16,5 +16,17 @@ export type IComment = {
   creator: IUser,
 };
 
+export interface ICommentPostArgs {
+  commentForm: {
+    comment: string,
+    revisionId: string,
+    replyTo: string|undefined
+  },
+  slackNotificationForm: {
+    isSlackEnabled: boolean|undefined,
+    slackChannels: string|undefined,
+  },
+}
+
 export type ICommentHasId = IComment & HasObjectId;
 export type ICommentHasIdList = ICommentHasId[];

+ 3 - 15
packages/app/src/stores/comment.tsx

@@ -2,7 +2,7 @@ import useSWR, { SWRResponse } from 'swr';
 
 import { apiGet, apiPost } from '~/client/util/apiv1-client';
 
-import { ICommentHasIdList } from '../interfaces/comment';
+import { ICommentHasIdList, ICommentPostArgs } from '../interfaces/comment';
 import { Nullable } from '../interfaces/common';
 
 type IResponseComment = {
@@ -10,21 +10,9 @@ type IResponseComment = {
   ok: boolean,
 }
 
-type CommentPost = {
-  commentForm: {
-    comment: string,
-    revisionId: string,
-    replyTo: string|undefined
-  },
-  slackNotificationForm: {
-    isSlackEnabled: boolean|undefined,
-    slackChannels: string|undefined,
-  },
-}
-
 type CommentOperation = {
   update(comment: string, revisionId: string, commentId: string): Promise<void>,
-  post(args: CommentPost): Promise<void>
+  post(args: ICommentPostArgs): Promise<void>
 }
 
 export const useSWRxPageComment = (pageId: Nullable<string>): SWRResponse<ICommentHasIdList, Error> & CommentOperation => {
@@ -47,7 +35,7 @@ export const useSWRxPageComment = (pageId: Nullable<string>): SWRResponse<IComme
     mutate();
   };
 
-  const post = async(args: CommentPost) => {
+  const post = async(args: ICommentPostArgs) => {
     const { mutate } = swrResponse;
     const { commentForm, slackNotificationForm } = args;
     const { comment, revisionId, replyTo } = commentForm;