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