arvid-e 4 месяцев назад
Родитель
Сommit
3793c7ecc6
2 измененных файлов с 13 добавлено и 15 удалено
  1. 1 0
      apps/app/src/interfaces/activity.ts
  2. 12 15
      apps/app/src/stores/recent-activity.ts

+ 1 - 0
apps/app/src/interfaces/activity.ts

@@ -5,6 +5,7 @@ import type {
   IUserHasId,
   Ref,
 } from '@growi/core';
+
 import type { PaginateResult } from './mongoose-utils';
 
 // Model

+ 12 - 15
apps/app/src/stores/recent-activity.ts

@@ -2,34 +2,31 @@ import type { SWRResponse } from 'swr';
 import useSWRImmutable from 'swr/immutable';
 
 import { apiv3Get } from '~/client/util/apiv3-client';
-import type { UserActivitiesResult, IActivityHasId } from '~/interfaces/activity';
+import type {
+  IActivityHasId,
+  UserActivitiesResult,
+} from '~/interfaces/activity';
 import type { PaginateResult } from '~/interfaces/mongoose-utils';
 
 export const useSWRxRecentActivity = (
-    limit?: number,
-    offset?: number,
-    targetUserId?: string,
+  limit?: number,
+  offset?: number,
+  targetUserId?: string,
 ): SWRResponse<PaginateResult<IActivityHasId>, Error> => {
-
   const shouldFetch = targetUserId && targetUserId.length > 0;
-  const key = shouldFetch ? ['/user-activities', limit, offset, targetUserId] : null;
-
-  const fetcher = ([
-    endpoint,
-    limitParam,
-    offsetParam,
-    targetUserIdParam,
-  ]) => {
+  const key = shouldFetch
+    ? ['/user-activities', limit, offset, targetUserId]
+    : null;
 
+  const fetcher = ([endpoint, limitParam, offsetParam, targetUserIdParam]) => {
     const promise = apiv3Get<UserActivitiesResult>(endpoint, {
       limit: limitParam,
       offset: offsetParam,
       targetUserId: targetUserIdParam,
     });
 
-    return promise.then(result => result.data.serializedPaginationResult);
+    return promise.then((result) => result.data.serializedPaginationResult);
   };
 
-
   return useSWRImmutable(key, fetcher);
 };