فهرست منبع

Eliminate STATUS_UNREAD

shironegi39 1 سال پیش
والد
کامیت
6beac6b841

+ 2 - 2
apps/app/src/client/components/InAppNotification/InAppNotificationElm.tsx

@@ -31,7 +31,7 @@ const InAppNotificationElm: FC<Props> = (props: Props) => {
   }
   }
 
 
   const clickHandler = async(notification: IInAppNotification & HasObjectId): Promise<void> => {
   const clickHandler = async(notification: IInAppNotification & HasObjectId): Promise<void> => {
-    if (notification.status === InAppNotificationStatuses.STATUS_UNREAD) {
+    if (notification.status === InAppNotificationStatuses.STATUS_UNOPENED) {
       // set notification status "OPEND"
       // set notification status "OPEND"
       await apiv3Post('/in-app-notification/open', { id: notification._id });
       await apiv3Post('/in-app-notification/open', { id: notification._id });
       onUnopenedNotificationOpend?.();
       onUnopenedNotificationOpend?.();
@@ -64,7 +64,7 @@ const InAppNotificationElm: FC<Props> = (props: Props) => {
     <div className="list-group-item list-group-item-action" onClick={() => clickHandler(notification)} style={{ cursor: 'pointer' }}>
     <div className="list-group-item list-group-item-action" onClick={() => clickHandler(notification)} style={{ cursor: 'pointer' }}>
       <div className="d-flex align-items-center">
       <div className="d-flex align-items-center">
         <span
         <span
-          className={`${notification.status === InAppNotificationStatuses.STATUS_UNREAD
+          className={`${notification.status === InAppNotificationStatuses.STATUS_UNOPENED
             ? 'grw-unopend-notification'
             ? 'grw-unopend-notification'
             : 'ms-2'
             : 'ms-2'
           } rounded-circle me-3`}
           } rounded-circle me-3`}

+ 1 - 1
apps/app/src/client/components/Sidebar/InAppNotification/InAppNotificationSubstance.tsx

@@ -42,7 +42,7 @@ export const InAppNotificationContent = (props: InAppNotificationContentProps):
   const { data: inAppNotificationData, mutate: mutateInAppNotificationData } = useSWRxInAppNotifications(
   const { data: inAppNotificationData, mutate: mutateInAppNotificationData } = useSWRxInAppNotifications(
     6,
     6,
     undefined,
     undefined,
-    isUnopendNotificationsVisible ? InAppNotificationStatuses.STATUS_UNREAD : undefined,
+    isUnopendNotificationsVisible ? InAppNotificationStatuses.STATUS_UNOPENED : undefined,
     { keepPreviousData: true },
     { keepPreviousData: true },
   );
   );
 
 

+ 1 - 1
apps/app/src/server/models/in-app-notification.ts

@@ -66,7 +66,7 @@ const inAppNotificationSchema = new Schema<InAppNotificationDocument, InAppNotif
   ],
   ],
   status: {
   status: {
     type: String,
     type: String,
-    default: STATUS_UNREAD,
+    default: STATUS_UNOPENED,
     enum: InAppNotificationStatuses,
     enum: InAppNotificationStatuses,
     index: true,
     index: true,
     required: true,
     required: true,

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

@@ -93,7 +93,7 @@ export default class InAppNotificationService {
         targetModel,
         targetModel,
         target,
         target,
         action,
         action,
-        status: STATUS_UNREAD,
+        status: STATUS_UNOPENED,
         createdAt: now,
         createdAt: now,
         snapshot,
         snapshot,
         $addToSet: { activities: activityId },
         $addToSet: { activities: activityId },
@@ -173,7 +173,7 @@ export default class InAppNotificationService {
   };
   };
 
 
   getUnreadCountByUser = async function(user: Types.ObjectId): Promise<number| undefined> {
   getUnreadCountByUser = async function(user: Types.ObjectId): Promise<number| undefined> {
-    const query = { user, status: STATUS_UNREAD };
+    const query = { user, status: STATUS_UNOPENED };
 
 
     try {
     try {
       const count = await InAppNotification.countDocuments(query);
       const count = await InAppNotification.countDocuments(query);