kaori 3 лет назад
Родитель
Сommit
3cdf3f7c65

+ 2 - 2
packages/app/src/components/Page/TagsInput.tsx

@@ -5,7 +5,7 @@ import { AsyncTypeahead } from 'react-bootstrap-typeahead';
 
 import { apiGet } from '~/client/util/apiv1-client';
 import { toastError } from '~/client/util/apiNotification';
-import { ITagsSearchApiv1Result } from '~/interfaces/tag';
+import { IResTagsSearchApiv1 } from '~/interfaces/tag';
 
 type TypeaheadInstance = {
   _handleMenuItemSelect: (activeItem: string, event: React.KeyboardEvent) => void,
@@ -36,7 +36,7 @@ const TagsInput: FC<Props> = (props: Props) => {
     setLoading(true);
     try {
       // TODO: 91698 SWRize
-      const res = await apiGet('/tags.search', { q: query }) as ITagsSearchApiv1Result;
+      const res = await apiGet('/tags.search', { q: query }) as IResTagsSearchApiv1;
       res.tags.unshift(query);
       setResultTags(Array.from(new Set(res.tags)));
     }

+ 2 - 2
packages/app/src/interfaces/page-tag-relation.ts

@@ -1,7 +1,7 @@
 import { IPage } from './page';
-import { IResTag } from './tag';
+import { ITag } from './tag';
 
 export type IPageTagRelation = {
   relatedPage: IPage,
-  relatedTag: IResTag,
+  relatedTag: ITag,
 }

+ 2 - 2
packages/app/src/interfaces/page.ts

@@ -2,7 +2,7 @@ import { Ref, Nullable } from './common';
 import { HasObjectId } from './has-object-id';
 import { IRevision, HasRevisionShortbody } from './revision';
 import { SubscriptionStatusType } from './subscription';
-import { IResTag } from './tag';
+import { ITag } from './tag';
 import { IUser } from './user';
 
 
@@ -10,7 +10,7 @@ export interface IPage {
   path: string,
   status: string,
   revision: Ref<IRevision>,
-  tags: Ref<IResTag>[],
+  tags: Ref<ITag>[],
   creator: Ref<IUser>,
   createdAt: Date,
   updatedAt: Date,

+ 4 - 4
packages/app/src/interfaces/tag.ts

@@ -1,17 +1,17 @@
-export type IResTag<ID = string> = {
+export type ITag<ID = string> = {
   _id: ID
   name: string,
 }
 
-export type IDataTagCount = IResTag & {count: number}
+export type IDataTagCount = ITag & {count: number}
 
 
-export type ITagsSearchApiv1Result = {
+export type IResTagsSearchApiv1 = {
   ok: boolean,
   tags: string[]
 }
 
-export type ITagsListApiv1Result = {
+export type IResTagsListApiv1 = {
   ok: boolean,
   data: IDataTagCount[],
   totalCount: number,

+ 3 - 3
packages/app/src/stores/tag.tsx

@@ -2,11 +2,11 @@ import { SWRResponse } from 'swr';
 import useSWRImmutable from 'swr/immutable';
 
 import { apiGet } from '~/client/util/apiv1-client';
-import { ITagsListApiv1Result } from '~/interfaces/tag';
+import { IResTagsListApiv1 } from '~/interfaces/tag';
 
-export const useSWRxTagsList = (limit?: number, offset?: number): SWRResponse<ITagsListApiv1Result, Error> => {
+export const useSWRxTagsList = (limit?: number, offset?: number): SWRResponse<IResTagsListApiv1, Error> => {
   return useSWRImmutable(
     ['/tags.list', limit, offset],
-    (endpoint, limit, offset) => apiGet(endpoint, { limit, offset }).then((result: ITagsListApiv1Result) => result),
+    (endpoint, limit, offset) => apiGet(endpoint, { limit, offset }).then((result: IResTagsListApiv1) => result),
   );
 };