Shun Miyazawa 4 лет назад
Родитель
Сommit
def6e7b30a
2 измененных файлов с 5 добавлено и 5 удалено
  1. 0 2
      packages/app/src/interfaces/tag.ts
  2. 5 3
      packages/app/src/stores/tag.tsx

+ 0 - 2
packages/app/src/interfaces/tag.ts

@@ -1,5 +1,3 @@
-export type Tag = string;
-
 export type ITag = {
   name: string,
   createdAt: Date;

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

@@ -1,18 +1,20 @@
 import { SWRResponse } from 'swr';
 import useSWRImmutable from 'swr/immutable';
 
-import { Tag } from '~/interfaces/tag';
+import { ITag } from '~/interfaces/tag';
 
 import { apiGet } from '../client/util/apiv1-client';
 
 
+export type ITagHasCount = ITag & { count: number }
+
 export type ITagsApiv1Result = {
   ok: boolean,
-  tags: Tag[],
+  data: ITagHasCount[],
   totalCount: number,
 }
 
 export const useSWRxTagsList = (limit?: number, offset?: number): SWRResponse<ITagsApiv1Result, Error> => {
   return useSWRImmutable(['/tags.list', limit, offset],
-    (endpoint, limit, offset) => apiGet(endpoint, { limit, offset }).then((response: ITagsApiv1Result) => response));
+    (endpoint, limit, offset) => apiGet(endpoint, { limit, offset }).then(response => response as ITagsApiv1Result));
 };