Skip to content

Commit 134644f

Browse files
[WEB-2382]chore:notification files restructuring (#6181)
* chore: adjusted increment/decrement for unread count * chore: improved param handling for unread notification count function * chore:file restructuring * fix:notification types * chore:file restructuring * chore:modified notfication types * chore: modified types for notification * chore:removed redundant checks for id
1 parent d0f3987 commit 134644f

File tree

8 files changed

+8
-21
lines changed

8 files changed

+8
-21
lines changed

packages/types/src/workspace-notifications.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export type TNotificationData = {
3535
};
3636

3737
export type TNotification = {
38-
id: string | undefined;
38+
id: string;
3939
title: string | undefined;
4040
data: TNotificationData | undefined;
4141
entity_identifier: string | undefined;

web/app/[workspaceSlug]/(projects)/notifications/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
// components
4-
import { NotificationsSidebarRoot } from "@/plane-web/components/workspace-notifications";
4+
import { NotificationsSidebarRoot } from "@/components/workspace-notifications";
55

66
export default function ProjectInboxIssuesLayout({ children }: { children: React.ReactNode }) {
77
return (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './root'
1+
export * from "./notification-card/root";

web/core/components/workspace-notifications/sidebar/notification-card/root.tsx renamed to web/ce/components/workspace-notifications/notification-card/root.tsx

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from "./notification-app-sidebar-option";
22
export * from "./sidebar";
3+
export * from "./root";

web/ce/components/workspace-notifications/root.tsx renamed to web/core/components/workspace-notifications/root.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
NotificationEmptyState,
1212
NotificationSidebarHeader,
1313
AppliedFilters,
14-
NotificationCardListRoot,
1514
} from "@/components/workspace-notifications";
1615
// constants
1716
import { NOTIFICATION_TABS, TNotificationTab } from "@/constants/notification";
@@ -21,6 +20,8 @@ import { getNumberCount } from "@/helpers/string.helper";
2120
// hooks
2221
import { useWorkspace, useWorkspaceNotifications } from "@/hooks/store";
2322

23+
import { NotificationCardListRoot } from "@/plane-web/components/workspace-notifications";
24+
2425
export const NotificationsSidebarRoot: FC = observer(() => {
2526
const { workspaceSlug } = useParams();
2627
// hooks
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export * from "./root";
21
export * from "./item";
32
export * from "./options";

web/core/store/notifications/notification.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface INotification extends TNotification {
2626

2727
export class Notification implements INotification {
2828
// observables
29-
id: string | undefined = undefined;
29+
id: string;
3030
title: string | undefined = undefined;
3131
data: TNotificationData | undefined = undefined;
3232
entity_identifier: string | undefined = undefined;
@@ -54,6 +54,7 @@ export class Notification implements INotification {
5454
private store: CoreRootStore,
5555
private notification: TNotification
5656
) {
57+
this.id = this.notification.id;
5758
makeObservable(this, {
5859
// observables
5960
id: observable.ref,
@@ -90,7 +91,6 @@ export class Notification implements INotification {
9091
snoozeNotification: action,
9192
unSnoozeNotification: action,
9293
});
93-
this.id = this.notification.id;
9494
this.title = this.notification.title;
9595
this.data = this.notification.data;
9696
this.entity_identifier = this.notification.entity_identifier;
@@ -169,8 +169,6 @@ export class Notification implements INotification {
169169
workspaceSlug: string,
170170
payload: Partial<TNotification>
171171
): Promise<TNotification | undefined> => {
172-
if (!this.id) return undefined;
173-
174172
try {
175173
const notification = await workspaceNotificationService.updateNotificationById(workspaceSlug, this.id, payload);
176174
if (notification) {
@@ -188,8 +186,6 @@ export class Notification implements INotification {
188186
* @returns { TNotification | undefined }
189187
*/
190188
markNotificationAsRead = async (workspaceSlug: string): Promise<TNotification | undefined> => {
191-
if (!this.id) return undefined;
192-
193189
const currentNotificationReadAt = this.read_at;
194190
try {
195191
const payload: Partial<TNotification> = {
@@ -215,8 +211,6 @@ export class Notification implements INotification {
215211
* @returns { TNotification | undefined }
216212
*/
217213
markNotificationAsUnRead = async (workspaceSlug: string): Promise<TNotification | undefined> => {
218-
if (!this.id) return undefined;
219-
220214
const currentNotificationReadAt = this.read_at;
221215
try {
222216
const payload: Partial<TNotification> = {
@@ -242,8 +236,6 @@ export class Notification implements INotification {
242236
* @returns { TNotification | undefined }
243237
*/
244238
archiveNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
245-
if (!this.id) return undefined;
246-
247239
const currentNotificationArchivedAt = this.archived_at;
248240
try {
249241
const payload: Partial<TNotification> = {
@@ -267,8 +259,6 @@ export class Notification implements INotification {
267259
* @returns { TNotification | undefined }
268260
*/
269261
unArchiveNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
270-
if (!this.id) return undefined;
271-
272262
const currentNotificationArchivedAt = this.archived_at;
273263
try {
274264
const payload: Partial<TNotification> = {
@@ -293,8 +283,6 @@ export class Notification implements INotification {
293283
* @returns { TNotification | undefined }
294284
*/
295285
snoozeNotification = async (workspaceSlug: string, snoozeTill: Date): Promise<TNotification | undefined> => {
296-
if (!this.id) return undefined;
297-
298286
const currentNotificationSnoozeTill = this.snoozed_till;
299287
try {
300288
const payload: Partial<TNotification> = {
@@ -315,8 +303,6 @@ export class Notification implements INotification {
315303
* @returns { TNotification | undefined }
316304
*/
317305
unSnoozeNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
318-
if (!this.id) return undefined;
319-
320306
const currentNotificationSnoozeTill = this.snoozed_till;
321307
try {
322308
const payload: Partial<TNotification> = {

0 commit comments

Comments
 (0)