kaori před 4 roky
rodič
revize
3f3e64dc77

+ 3 - 2
packages/app/src/server/service/in-app-notification.ts

@@ -82,15 +82,16 @@ export default class InAppNotificationService {
   }
 
   getLatestNotificationsByUser = async(userId, queryOptions) => {
-    const { offset, limit } = queryOptions;
+    const { limit } = queryOptions;
+    const offset = queryOptions.offset || 0;
 
     try {
       const paginationResult = await InAppNotification.paginate(
         { user: userId },
         {
           sort: { createdAt: -1 },
-          offset,
           limit,
+          offset,
           populate: [
             { path: 'user' },
             { path: 'target' },

+ 1 - 1
packages/app/src/stores/in-app-notification.ts

@@ -8,7 +8,7 @@ import { IInAppNotification } from '../interfaces/in-app-notification';
 // eslint-disable-next-line @typescript-eslint/no-unused-vars
 export const useSWRxInAppNotifications = <Data, Error>(
   limit: number,
-  offset: number,
+  offset?: number,
 ): SWRResponse<PaginateResult<IInAppNotification>, Error> => {
   return useSWR(
     `/in-app-notification/list?limit=${limit}&offset=${offset}`,