diff --git a/web/core/components/workspace-notifications/root.tsx b/web/core/components/workspace-notifications/root.tsx
index fa17060d59..1c38678564 100644
--- a/web/core/components/workspace-notifications/root.tsx
+++ b/web/core/components/workspace-notifications/root.tsx
@@ -1,6 +1,6 @@
"use client";
-
import { FC, useCallback } from "react";
+
import { observer } from "mobx-react";
import { useParams } from "next/navigation";
// components
@@ -19,8 +19,10 @@ import { cn } from "@/helpers/common.helper";
import { getNumberCount } from "@/helpers/string.helper";
// hooks
import { useWorkspace, useWorkspaceNotifications } from "@/hooks/store";
+import { useFlag } from "@/plane-web/hooks/store";
-import { NotificationCardListRoot } from "@/plane-web/components/workspace-notifications";
+import { NotificationCardListRoot as NotificationCardListRootCe } from "ce/components/workspace-notifications";
+import { NotificationCardListRoot as NotificationCardListRootEe } from "ee/components/workspace-notifications";
export const NotificationsSidebarRoot: FC = observer(() => {
const { workspaceSlug } = useParams();
@@ -47,16 +49,18 @@ export const NotificationsSidebarRoot: FC = observer(() => {
[currentNotificationTab, setCurrentNotificationTab]
);
+ const isFeatureEnabled = useFlag(workspaceSlug.toString(), "INBOX_STACKING");
+
if (!workspaceSlug || !workspace) return <>>;
return (
-
+
@@ -100,7 +104,11 @@ export const NotificationsSidebarRoot: FC = observer(() => {
<>
{notificationIds && notificationIds.length > 0 ? (
-
+ {isFeatureEnabled ? (
+
+ ) : (
+
+ )}
) : (
diff --git a/web/ee/components/workspace-notifications/index.ts b/web/ee/components/workspace-notifications/index.ts
index ff8925d4e1..5f9897922a 100644
--- a/web/ee/components/workspace-notifications/index.ts
+++ b/web/ee/components/workspace-notifications/index.ts
@@ -1,2 +1 @@
-export * from "./root";
export * from "./notification-card";
diff --git a/web/ee/components/workspace-notifications/notification-card/item.tsx b/web/ee/components/workspace-notifications/notification-card/item.tsx
index a418d5fce2..8c7308e354 100644
--- a/web/ee/components/workspace-notifications/notification-card/item.tsx
+++ b/web/ee/components/workspace-notifications/notification-card/item.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import { FC, useMemo, useState, Fragment } from "react";
import { uniq } from "lodash";
import orderBy from "lodash/orderBy";
@@ -27,25 +29,29 @@ export const NotificationItem: FC
= observer((props) => {
const [isSnoozeStateModalOpen, setIsSnoozeStateModalOpen] = useState(false);
const [customSnoozeModal, setCustomSnoozeModal] = useState(false);
//hooks
- const { groupedNotificationsByIssueId, markNotificationGroupRead, hasInboxIssue, setCurrentSelectedNotificationId } =
- useWorkspaceNotifications();
+ const {
+ getNotificationsGroupedByIssue,
+ markBulkNotificationsAsRead,
+ containsInboxIssue,
+ setCurrentSelectedNotificationId,
+ } = useWorkspaceNotifications();
const { getIsIssuePeeked, setPeekIssue } = useIssueDetail();
//derived values
- const groupedNotifications = groupedNotificationsByIssueId(workspaceId);
- const notificationGroup = groupedNotifications[issueId];
- const issue = notificationGroup[0].data?.issue;
- const unreadCount = notificationGroup.filter((e) => !e.read_at).length;
- const projectId = notificationGroup[0].project;
+ const groupedNotifications = getNotificationsGroupedByIssue(workspaceId);
+ const notificationList = groupedNotifications[issueId];
+ const issue = notificationList[0].data?.issue;
+ const unreadCount = notificationList.filter((e) => !e.read_at).length;
+ const projectId = notificationList[0].project;
const authorIds: string[] = uniq(
- notificationGroup.map((e) => e.triggered_by).filter((id): id is string => id != undefined && id != null)
+ notificationList.map((e) => e.triggered_by).filter((id): id is string => id != undefined && id != null)
);
const latestNotificationTime = useMemo(() => {
- const latestNotification = orderBy(notificationGroup, (n) => convertToEpoch(n.created_at), "desc")[0];
+ const latestNotification = orderBy(notificationList, (n) => convertToEpoch(n.created_at), "desc")[0];
if (latestNotification.created_at) return calculateTimeAgo(latestNotification.created_at);
- }, [notificationGroup]);
+ }, [notificationList]);
const { styles, attributes } = usePopper(referenceElement, popperElement, {
placement: "right-start",
@@ -54,18 +60,18 @@ export const NotificationItem: FC = observer((props) => {
const handleNotificationIssuePeekOverview = async () => {
if (workspaceSlug && projectId && issueId && !isSnoozeStateModalOpen && !customSnoozeModal) {
setPeekIssue(undefined);
- setCurrentSelectedNotificationId(notificationGroup[0].id);
+ setCurrentSelectedNotificationId(notificationList[0].id);
// make the notification as read
if (unreadCount > 0) {
try {
- await markNotificationGroupRead(notificationGroup, workspaceSlug);
+ await markBulkNotificationsAsRead(notificationList, workspaceSlug);
} catch (error) {
console.error(error);
}
}
- if (!hasInboxIssue(notificationGroup)) {
+ if (!containsInboxIssue(notificationList)) {
if (!getIsIssuePeeked(issueId)) setPeekIssue({ workspaceSlug, projectId, issueId });
}
}
@@ -74,7 +80,7 @@ export const NotificationItem: FC = observer((props) => {
// states
const [showPreview, setShowPreview] = useState(false);
- if (!notificationGroup || !issue || !issue.id || !authorIds || !projectId) return <>>;
+ if (!notificationList || !issue || !issue.id || !authorIds || !projectId) return <>>;
return (
@@ -107,7 +113,7 @@ export const NotificationItem: FC = observer((props) => {
workspaceSlug={workspaceSlug}
issueId={issueId}
unreadCount={unreadCount}
- notificationGroup={notificationGroup}
+ notificationList={notificationList}
isSnoozeStateModalOpen={isSnoozeStateModalOpen}
setIsSnoozeStateModalOpen={setIsSnoozeStateModalOpen}
customSnoozeModal={customSnoozeModal}
@@ -147,7 +153,7 @@ export const NotificationItem: FC = observer((props) => {
= observer((props) => {
- const { workspaceSlug, notificationGroup, issueId } = props;
+ const { workspaceSlug, notificationList, issueId } = props;
// hooks
const { captureEvent } = useEventTracker();
const { currentNotificationTab } = useWorkspaceNotifications();
//derived values
- const archivedCount = notificationGroup.filter(n=>!!n.archived_at).length;
+ const archivedCount = notificationList.filter((n) => !!n.archived_at).length;
- const { archiveNotificationGroup, unArchiveNotificationGroup } = useWorkspaceNotifications()
+ const { archiveNotificationList, unArchiveNotificationList } = useWorkspaceNotifications();
const handleNotificationUpdate = async () => {
try {
- const request = archivedCount > 0 ? unArchiveNotificationGroup : archiveNotificationGroup;
- await request(notificationGroup,workspaceSlug);
+ const request = archivedCount > 0 ? unArchiveNotificationList : archiveNotificationList;
+ await request(notificationList, workspaceSlug);
captureEvent(NOTIFICATION_ARCHIVED, {
issue_id: issueId,
tab: currentNotificationTab,
diff --git a/web/ee/components/workspace-notifications/notification-card/options/read.tsx b/web/ee/components/workspace-notifications/notification-card/options/read.tsx
index 65d9b5c663..38c27ce571 100644
--- a/web/ee/components/workspace-notifications/notification-card/options/read.tsx
+++ b/web/ee/components/workspace-notifications/notification-card/options/read.tsx
@@ -15,23 +15,23 @@ import { INotification } from "@/store/notifications/notification";
type TNotificationItemReadOption = {
workspaceSlug: string;
- notificationGroup: INotification[];
+ notificationList: INotification[];
issueId: string;
- unreadCount: number
+ unreadCount: number;
};
export const NotificationItemReadOption: FC = observer((props) => {
- const { workspaceSlug, notificationGroup, issueId, unreadCount } = props;
+ const { workspaceSlug, notificationList, issueId, unreadCount } = props;
// hooks
const { captureEvent } = useEventTracker();
const { currentNotificationTab } = useWorkspaceNotifications();
- const { markNotificationGroupRead, markNotificationGroupUnRead } = useWorkspaceNotifications();
+ const { markBulkNotificationsAsRead, markBulkNotificationsAsUnread } = useWorkspaceNotifications();
const handleNotificationUpdate = async () => {
try {
- const request = unreadCount === 0 ? markNotificationGroupUnRead : markNotificationGroupRead;
- await request(notificationGroup,workspaceSlug);
+ const request = unreadCount === 0 ? markBulkNotificationsAsUnread : markBulkNotificationsAsRead;
+ await request(notificationList, workspaceSlug);
captureEvent(NOTIFICATIONS_READ, {
issue_id: issueId,
tab: currentNotificationTab,
diff --git a/web/ee/components/workspace-notifications/notification-card/options/root.tsx b/web/ee/components/workspace-notifications/notification-card/options/root.tsx
index d2b6836199..5db01e3ac5 100644
--- a/web/ee/components/workspace-notifications/notification-card/options/root.tsx
+++ b/web/ee/components/workspace-notifications/notification-card/options/root.tsx
@@ -6,7 +6,6 @@ import { observer } from "mobx-react";
// helpers
import { cn } from "@/helpers/common.helper";
// hooks
-import { useNotification } from "@/hooks/store";
import {
NotificationItemReadOption,
NotificationItemArchiveOption,
@@ -16,7 +15,7 @@ import { INotification } from "@/store/notifications/notification";
type TNotificationOption = {
workspaceSlug: string;
- notificationGroup: INotification[];
+ notificationList: INotification[];
issueId: string;
unreadCount: number;
isSnoozeStateModalOpen: boolean;
@@ -28,7 +27,7 @@ type TNotificationOption = {
export const NotificationOption: FC = observer((props) => {
const {
workspaceSlug,
- notificationGroup,
+ notificationList,
issueId,
unreadCount,
isSnoozeStateModalOpen,
@@ -43,7 +42,7 @@ export const NotificationOption: FC = observer((props) => {
{/* read */}
@@ -51,14 +50,14 @@ export const NotificationOption: FC = observer((props) => {
{/* archive */}
{/* snooze notification */}
>;
customSnoozeModal: boolean;
setCustomSnoozeModal: Dispatch>;
};
export const NotificationItemSnoozeOption: FC = observer((props) => {
- const { workspaceSlug, notificationGroup, setIsSnoozeStateModalOpen, customSnoozeModal, setCustomSnoozeModal } =
- props;
+ const { workspaceSlug, notificationList, setIsSnoozeStateModalOpen, customSnoozeModal, setCustomSnoozeModal } = props;
// hooks
const { isMobile } = usePlatformOS();
- const { snoozeNotificationGroup, unSnoozeNotificationGroup } = useWorkspaceNotifications();
+ const { snoozeNotificationList, unSnoozeNotificationList } = useWorkspaceNotifications();
- const snoozedCount = notificationGroup.filter((n) => !!n.snoozed_till).length;
+ const snoozedCount = notificationList.filter((n) => !!n.snoozed_till).length;
const handleNotificationSnoozeDate = async (snoozeTill: Date | undefined) => {
if (snoozedCount === 0 && snoozeTill) {
try {
- await snoozeNotificationGroup(notificationGroup, workspaceSlug, snoozeTill);
+ await snoozeNotificationList(notificationList, workspaceSlug, snoozeTill);
setToast({
title: "Success!",
message: "Notification(s) snoozed successfully",
@@ -47,7 +46,7 @@ export const NotificationItemSnoozeOption: FC = o
}
} else {
try {
- await unSnoozeNotificationGroup(notificationGroup, workspaceSlug);
+ await unSnoozeNotificationList(notificationList, workspaceSlug);
setToast({
title: "Success!",
message: "Notification(s) un snoozed successfully",
diff --git a/web/ee/components/workspace-notifications/notification-card/preview/acitvity-block.tsx b/web/ee/components/workspace-notifications/notification-card/preview/acitvity-block.tsx
index 58e8bed866..57b62e0c84 100644
--- a/web/ee/components/workspace-notifications/notification-card/preview/acitvity-block.tsx
+++ b/web/ee/components/workspace-notifications/notification-card/preview/acitvity-block.tsx
@@ -30,28 +30,29 @@ type TIssueActivityBlock = {
triggeredBy: IUserLite | undefined;
};
+export const acitvityIconsMap: Record = {
+ state: ,
+ name: ,
+ description: ,
+ assignees: ,
+ priority: ,
+ estimate_point: ,
+ parent: ,
+ start_date: ,
+ target_date: ,
+ cycles: ,
+ modules: ,
+ labels: ,
+ link: ,
+ attachment: ,
+ archived_at: ,
+ inbox: ,
+ type: ,
+};
+
export const IssueActivityBlock: FC = (props) => {
const { ends, children, createdAt, notificationField, triggeredBy } = props;
- const acitvityIconsMap: Record = {
- state: ,
- name: ,
- description: ,
- assignees: ,
- priority: ,
- estimate_point: ,
- parent: ,
- start_date: ,
- target_date: ,
- cycles: ,
- modules: ,
- labels: ,
- link: ,
- attachment: ,
- archived_at: ,
- inbox: ,
- type: ,
- };
const { isMobile } = usePlatformOS();
return (
= (props) => {
- const { notificationGroup, workspaceSlug, projectId, issueData } = props;
- const unreadCount = notificationGroup.filter((e) => !e.read_at).length;
+ const { notificationList, workspaceSlug, projectId, issueData } = props;
+ const unreadCount = notificationList.filter((e) => !e.read_at).length;
const issueType = useIssueType(issueData.id);
@@ -36,7 +38,7 @@ export const NotificationCardPreview: FC
= (props) =>
{issueData.name}
- {orderBy(notificationGroup, (n) => convertToEpoch(n.created_at), "desc")
+ {orderBy(notificationList, (n) => convertToEpoch(n.created_at), "desc")
.filter((n) => !!n)
.map((notification, index, { length }) => (
= observer((props) => {
const { workspaceSlug, workspaceId } = props;
// hooks
- const { loader, paginationInfo, getNotifications, notificationIssueIdsByWorkspaceId } = useWorkspaceNotifications();
- const notificationIssueIds = notificationIssueIdsByWorkspaceId(workspaceId);
+ const { loader, paginationInfo, getNotifications, getIssueIdsSortedByLatestNotification } =
+ useWorkspaceNotifications();
+ const notificationIssueIds = getIssueIdsSortedByLatestNotification(workspaceId);
const getNextNotifications = async () => {
try {
diff --git a/web/ee/components/workspace-notifications/root.tsx b/web/ee/components/workspace-notifications/root.tsx
deleted file mode 100644
index 72d72b7b7c..0000000000
--- a/web/ee/components/workspace-notifications/root.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-// export * from "./sidebar";
-
-import React, { useMemo } from "react";
-import dynamic from "next/dynamic";
-import { useParams } from "next/navigation";
-import { useFlag } from "@/plane-web/hooks/store";
-
-export const NotificationsSidebarRoot = () => {
- const { workspaceSlug } = useParams();
- const isFeatureEnabled = useFlag(workspaceSlug.toString(), "INBOX_STACKING");
- const NotificationsSideBarRoot = useMemo(
- () =>
- dynamic(
- () =>
- isFeatureEnabled
- ? import(`ee/components/workspace-notifications/sidebar`).then((module) => ({
- default: module["NotificationsSidebar"],
- }))
- : import("ce/components/workspace-notifications/root").then((module) => ({
- default: module["NotificationsSidebarRoot"],
- })),
- {
- // TODO: Add loading component
- loading: () => <>>,
- }
- ),
- [isFeatureEnabled]
- );
-
- return ;
-};
diff --git a/web/ee/components/workspace-notifications/sidebar.tsx b/web/ee/components/workspace-notifications/sidebar.tsx
deleted file mode 100644
index fb10fb41ad..0000000000
--- a/web/ee/components/workspace-notifications/sidebar.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-"use client";
-
-import { FC } from "react";
-import { observer } from "mobx-react";
-import { useParams } from "next/navigation";
-// components
-import { Header, Row, ERowVariant, EHeaderVariant, ContentWrapper } from "@plane/ui";
-import { CountChip } from "@/components/common";
-import {
- NotificationsLoader,
- NotificationEmptyState,
- NotificationSidebarHeader,
- AppliedFilters,
-} from "@/components/workspace-notifications";
-// constants
-import { NOTIFICATION_TABS } from "@/constants/notification";
-// helpers
-import { cn } from "@/helpers/common.helper";
-import { getNumberCount } from "@/helpers/string.helper";
-// hooks
-import { useWorkspace, useWorkspaceNotifications } from "@/hooks/store";
-// plane web components
-import { NotificationCardListRoot } from "@/plane-web/components/workspace-notifications";
-
-export const NotificationsSidebar: FC = observer(() => {
- const { workspaceSlug } = useParams();
- // hooks
- const { getWorkspaceBySlug } = useWorkspace();
- const {
- currentSelectedNotificationId,
- unreadNotificationsCount,
- loader,
- notificationIssueIdsByWorkspaceId,
- currentNotificationTab,
- setCurrentNotificationTab,
- } = useWorkspaceNotifications();
- // derived values
- const workspace = workspaceSlug ? getWorkspaceBySlug(workspaceSlug.toString()) : undefined;
- const groupedNotificationIssueIds = workspace ? notificationIssueIdsByWorkspaceId(workspace.id) : undefined;
-
- if (!workspaceSlug || !workspace) return <>>;
-
- return (
-
-
-
-
-
-
-
-
- {/* applied filters */}
-
-
- {/* rendering notifications */}
- {loader === "init-loader" ? (
-
-
-
- ) : (
- <>
- {groupedNotificationIssueIds && groupedNotificationIssueIds.length > 0 ? (
-
-
-
- ) : (
-
-
-
- )}
- >
- )}
-
-
- );
-});
diff --git a/web/ee/services/inbox.service.ts b/web/ee/services/inbox.service.ts
index 6f871bb912..d688298aa0 100644
--- a/web/ee/services/inbox.service.ts
+++ b/web/ee/services/inbox.service.ts
@@ -1,23 +1,23 @@
import { WorkspaceNotificationService } from "@/services/workspace-notification.service";
export class InboxService extends WorkspaceNotificationService {
- async markNotificationGroupRead(workspaceSlug: string, payload: { notification_ids: string[] }) {
+ async markBulkNotificationsAsRead(workspaceSlug: string, payload: { notification_ids: string[] }) {
await this.post(`/api/workspaces/${workspaceSlug}/inbox/read/`, payload);
}
- async markNotificationGroupUnRead(workspaceSlug: string, payload: { notification_ids: string[] }) {
+ async markBulkNotificationsAsUnread(workspaceSlug: string, payload: { notification_ids: string[] }) {
await this.delete(`/api/workspaces/${workspaceSlug}/inbox/read/`, payload);
}
- async archiveNotificationGroup(workspaceSlug: string, payload: { notification_ids: string[] }) {
+ async archiveNotificationList(workspaceSlug: string, payload: { notification_ids: string[] }) {
await this.post(`/api/workspaces/${workspaceSlug}/inbox/archive/`, payload);
}
- async unArchiveNotificationGroup(workspaceSlug: string, payload: { notification_ids: string[] }) {
+ async unArchiveNotificationList(workspaceSlug: string, payload: { notification_ids: string[] }) {
await this.delete(`/api/workspaces/${workspaceSlug}/inbox/archive/`, payload);
}
- async updateNotficationGroup(
+ async updateNotficationList(
workspaceSlug: string,
payload: { notification_ids: string[]; snoozed_till: string | undefined }
) {
diff --git a/web/ee/store/notifications/notifications.store.ts b/web/ee/store/notifications/notifications.store.ts
index 118edc23e2..2c42cb534b 100644
--- a/web/ee/store/notifications/notifications.store.ts
+++ b/web/ee/store/notifications/notifications.store.ts
@@ -1,5 +1,4 @@
import orderBy from "lodash/orderBy";
-import uniqBy from "lodash/uniqBy";
import { runInAction } from "mobx";
import { computedFn } from "mobx-utils";
import { TNotification } from "@plane/types";
@@ -19,39 +18,44 @@ import {
export type TGroupedNotifications = Record;
export interface IWorkspaceNotificationStore extends IWorkspaceNotificationStoreCore {
- groupedNotificationsByIssueId: (workspaceId: string) => Record;
- notificationIssueIdsByWorkspaceId: (workspaceId: string) => string[] | undefined;
- markNotificationGroupRead: (notificationGroup: INotification[], workspaceSlug: string) => Promise;
- markNotificationGroupUnRead: (notificationGroup: INotification[], workspaceSlug: string) => Promise;
- archiveNotificationGroup: (notificationGroup: INotification[], workspaceSlug: string) => Promise;
- unArchiveNotificationGroup: (notificationGroup: INotification[], workspaceSlug: string) => Promise;
- snoozeNotificationGroup: (
- notificationGroup: INotification[],
+ getNotificationsGroupedByIssue: (workspaceId: string) => Record;
+ getIssueIdsSortedByLatestNotification: (workspaceId: string) => string[] | undefined;
+ markBulkNotificationsAsRead: (notitificationList: INotification[], workspaceSlug: string) => Promise;
+ markBulkNotificationsAsUnread: (notitificationList: INotification[], workspaceSlug: string) => Promise;
+ archiveNotificationList: (notitificationList: INotification[], workspaceSlug: string) => Promise;
+ unArchiveNotificationList: (notitificationList: INotification[], workspaceSlug: string) => Promise;
+ snoozeNotificationList: (
+ notitificationList: INotification[],
workspaceSlug: string,
- snoozeTill: Date
+ snoozeUntil: Date
) => Promise;
- unSnoozeNotificationGroup: (notificationGroup: INotification[], workspaceSlug: string) => Promise;
- hasInboxIssue: (notificationGroup: INotification[]) => boolean;
+ unSnoozeNotificationList: (notitificationList: INotification[], workspaceSlug: string) => Promise;
+ containsInboxIssue: (notitificationList: INotification[]) => boolean;
}
export class WorkspaceNotificationStore extends WorkspaceNotificationStoreCore implements IWorkspaceNotificationStore {
constructor(protected store: RootStore) {
super(store);
}
- groupedNotificationsByIssueId = computedFn((workspaceId: string) => {
- const filteredNotificationsIds = this.notificationIdsByWorkspaceId(workspaceId);
- if (!filteredNotificationsIds) return {};
- const groupedNotifications: Record = {};
+ getNotificationsGroupedByIssue = computedFn((workspaceId: string) => {
+ const notificationIds = this.notificationIdsByWorkspaceId(workspaceId);
+ if (!notificationIds) return {};
- filteredNotificationsIds.forEach((id) => {
- const entityId = this.notifications[id].entity_identifier;
- if (!entityId) return;
- const existingNotifications = groupedNotifications[entityId] || [];
- groupedNotifications[entityId] = uniqBy([...existingNotifications, this.notifications[id]], "id");
- });
+ return notificationIds.reduce>((groupedNotifications, id) => {
+ const notification = this.notifications[id];
+ const entityId = notification.entity_identifier;
- return groupedNotifications;
+ if (!entityId) return groupedNotifications;
+
+ if (!groupedNotifications[entityId]) {
+ groupedNotifications[entityId] = [];
+ }
+
+ groupedNotifications[entityId].push(notification);
+
+ return groupedNotifications;
+ }, {});
});
/**
@@ -59,8 +63,8 @@ export class WorkspaceNotificationStore extends WorkspaceNotificationStoreCore i
* @param workspaceId: string
* @returns string[]
*/
- notificationIssueIdsByWorkspaceId = computedFn((workspaceId: string) => {
- const groupedNotifications: Record = this.groupedNotificationsByIssueId(workspaceId);
+ getIssueIdsSortedByLatestNotification = computedFn((workspaceId: string) => {
+ const groupedNotifications: Record = this.getNotificationsGroupedByIssue(workspaceId);
const groupedNotificationIssueIds = orderBy(
Object.keys(groupedNotifications),
@@ -75,21 +79,15 @@ export class WorkspaceNotificationStore extends WorkspaceNotificationStoreCore i
return groupedNotificationIssueIds;
});
- /**
- * @description Marks a group of notificaitons read
- * @param notificationGroup : INotification[]
- */
- markNotificationGroupRead = async (notificationGroup: INotification[], workspaceSlug: string) => {
+ markBulkNotificationsAsRead = async (notificationGroup: INotification[], workspaceSlug: string) => {
const unreadNotificationGroup = notificationGroup.filter((n) => !n.read_at);
if (unreadNotificationGroup.length === 0) return;
try {
this.loader = ENotificationLoader.MUTATION_LOADER;
- const notification_ids: string[] = unreadNotificationGroup
- .filter((n): n is INotification & { id: string } => !!n.id)
- .map((n) => n.id);
+ const notification_ids: string[] = unreadNotificationGroup.map((n) => n.id);
- await inboxService.markNotificationGroupRead(workspaceSlug, {
+ await inboxService.markBulkNotificationsAsRead(workspaceSlug, {
notification_ids,
});
@@ -107,22 +105,15 @@ export class WorkspaceNotificationStore extends WorkspaceNotificationStoreCore i
}
};
- /**
- * @description Marks group of notifications unread
- * @param notificationGroup : INotification[]
- * @param workspaceSlug : string
- */
- markNotificationGroupUnRead = async (notificationGroup: INotification[], workspaceSlug: string) => {
+ markBulkNotificationsAsUnread = async (notificationGroup: INotification[], workspaceSlug: string) => {
const readNotificationGroup = notificationGroup.filter((n) => n.read_at);
if (readNotificationGroup.length === 0) return;
try {
this.loader = ENotificationLoader.MUTATION_LOADER;
- const notification_ids: string[] = readNotificationGroup
- .filter((n): n is INotification & { id: string } => !!n.id)
- .map((n) => n.id);
+ const notification_ids: string[] = readNotificationGroup.map((n) => n.id);
- await inboxService.markNotificationGroupUnRead(workspaceSlug, {
+ await inboxService.markBulkNotificationsAsUnread(workspaceSlug, {
notification_ids,
});
@@ -140,18 +131,11 @@ export class WorkspaceNotificationStore extends WorkspaceNotificationStoreCore i
}
};
- /**
- * @description Archives group of notifications
- * @param notificationGroup : INotification[]
- * @param workspaceSlug : string
- */
- archiveNotificationGroup = async (notificationGroup: INotification[], workspaceSlug: string) => {
+ archiveNotificationList = async (notificationGroup: INotification[], workspaceSlug: string) => {
try {
- const notification_ids: string[] = notificationGroup
- .filter((n): n is INotification & { id: string } => !!n.id)
- .map((n) => n.id);
+ const notification_ids: string[] = notificationGroup.map((n) => n.id);
- await inboxService.archiveNotificationGroup(workspaceSlug, { notification_ids });
+ await inboxService.archiveNotificationList(workspaceSlug, { notification_ids });
Object.values(notificationGroup).forEach((notification) => {
notification.mutateNotification({ archived_at: new Date().toISOString() });
@@ -162,18 +146,11 @@ export class WorkspaceNotificationStore extends WorkspaceNotificationStoreCore i
}
};
- /**
- * @description Un archives group of notifications
- * @param notificationGroup: INotification[]
- * @param workspaceSlug: string
- */
- unArchiveNotificationGroup = async (notificationGroup: INotification[], workspaceSlug: string) => {
+ unArchiveNotificationList = async (notificationGroup: INotification[], workspaceSlug: string) => {
try {
- const notification_ids: string[] = notificationGroup
- .filter((n): n is INotification & { id: string } => !!n.id)
- .map((n) => n.id);
+ const notification_ids: string[] = notificationGroup.map((n) => n.id);
- await inboxService.unArchiveNotificationGroup(workspaceSlug, { notification_ids });
+ await inboxService.unArchiveNotificationList(workspaceSlug, { notification_ids });
Object.values(notificationGroup).forEach((notification) => {
notification.mutateNotification({ archived_at: undefined });
@@ -184,26 +161,18 @@ export class WorkspaceNotificationStore extends WorkspaceNotificationStoreCore i
}
};
- /**
- * @description Snoozes group of notifications unitl the provided date and time
- * @param notificationGroup : INotification[]
- * @param workspaceSlug : string
- * @param snoozed_till : Date
- */
- snoozeNotificationGroup = async (notificationGroup: INotification[], workspaceSlug: string, snoozeTill: Date) => {
+ snoozeNotificationList = async (notificationGroup: INotification[], workspaceSlug: string, snoozeUntil: Date) => {
try {
- const notification_ids: string[] = notificationGroup
- .filter((n): n is INotification & { id: string } => !!n.id)
- .map((n) => n.id);
+ const notification_ids: string[] = notificationGroup.map((n) => n.id);
- await inboxService.updateNotficationGroup(workspaceSlug, {
+ await inboxService.updateNotficationList(workspaceSlug, {
notification_ids,
- snoozed_till: snoozeTill.toISOString(),
+ snoozed_till: snoozeUntil.toISOString(),
});
runInAction(() => {
Object.values(notificationGroup).forEach((notification) => {
- notification.mutateNotification({ snoozed_till: snoozeTill.toISOString() });
+ notification.mutateNotification({ snoozed_till: snoozeUntil.toISOString() });
});
});
} catch (error) {
@@ -212,19 +181,11 @@ export class WorkspaceNotificationStore extends WorkspaceNotificationStoreCore i
}
};
- /**
- * @description Un Snoozes group of notifications unitl the provided date and time
- * @param notificationGroup : INotification[]
- * @param workspaceSlug : string
- * @param snoozed_till : Date
- */
- unSnoozeNotificationGroup = async (notificationGroup: INotification[], workspaceSlug: string) => {
+ unSnoozeNotificationList = async (notificationGroup: INotification[], workspaceSlug: string) => {
try {
- const notification_ids: string[] = notificationGroup
- .filter((n): n is INotification & { id: string } => !!n.id)
- .map((n) => n.id);
+ const notification_ids: string[] = notificationGroup.map((n) => n.id);
- await inboxService.updateNotficationGroup(workspaceSlug, {
+ await inboxService.updateNotficationList(workspaceSlug, {
notification_ids,
snoozed_till: undefined,
});
@@ -240,12 +201,7 @@ export class WorkspaceNotificationStore extends WorkspaceNotificationStoreCore i
}
};
- /**
- * Checks if notification group has an inbox issue
- * @param notificationGroup : INotification[]
- * @returns boolean
- */
- hasInboxIssue = (notificationGroup: INotification[]) => {
+ containsInboxIssue = (notificationGroup: INotification[]) => {
const inbox_issue = notificationGroup.find((notification) => notification.is_inbox_issue);
if (inbox_issue) return true;
return false;