[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
This commit is contained in:
Vamsi Krishna 2024-12-11 13:41:19 +05:30 committed by GitHub
parent d0f3987aeb
commit 134644fdf1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 8 additions and 21 deletions

View file

@ -35,7 +35,7 @@ export type TNotificationData = {
};
export type TNotification = {
id: string | undefined;
id: string;
title: string | undefined;
data: TNotificationData | undefined;
entity_identifier: string | undefined;

View file

@ -1,7 +1,7 @@
"use client";
// components
import { NotificationsSidebarRoot } from "@/plane-web/components/workspace-notifications";
import { NotificationsSidebarRoot } from "@/components/workspace-notifications";
export default function ProjectInboxIssuesLayout({ children }: { children: React.ReactNode }) {
return (

View file

@ -1 +1 @@
export * from './root'
export * from "./notification-card/root";

View file

@ -1,2 +1,3 @@
export * from "./notification-app-sidebar-option";
export * from "./sidebar";
export * from "./root";

View file

@ -11,7 +11,6 @@ import {
NotificationEmptyState,
NotificationSidebarHeader,
AppliedFilters,
NotificationCardListRoot,
} from "@/components/workspace-notifications";
// constants
import { NOTIFICATION_TABS, TNotificationTab } from "@/constants/notification";
@ -21,6 +20,8 @@ import { getNumberCount } from "@/helpers/string.helper";
// hooks
import { useWorkspace, useWorkspaceNotifications } from "@/hooks/store";
import { NotificationCardListRoot } from "@/plane-web/components/workspace-notifications";
export const NotificationsSidebarRoot: FC = observer(() => {
const { workspaceSlug } = useParams();
// hooks

View file

@ -1,3 +1,2 @@
export * from "./root";
export * from "./item";
export * from "./options";

View file

@ -26,7 +26,7 @@ export interface INotification extends TNotification {
export class Notification implements INotification {
// observables
id: string | undefined = undefined;
id: string;
title: string | undefined = undefined;
data: TNotificationData | undefined = undefined;
entity_identifier: string | undefined = undefined;
@ -54,6 +54,7 @@ export class Notification implements INotification {
private store: CoreRootStore,
private notification: TNotification
) {
this.id = this.notification.id;
makeObservable(this, {
// observables
id: observable.ref,
@ -90,7 +91,6 @@ export class Notification implements INotification {
snoozeNotification: action,
unSnoozeNotification: action,
});
this.id = this.notification.id;
this.title = this.notification.title;
this.data = this.notification.data;
this.entity_identifier = this.notification.entity_identifier;
@ -169,8 +169,6 @@ export class Notification implements INotification {
workspaceSlug: string,
payload: Partial<TNotification>
): Promise<TNotification | undefined> => {
if (!this.id) return undefined;
try {
const notification = await workspaceNotificationService.updateNotificationById(workspaceSlug, this.id, payload);
if (notification) {
@ -188,8 +186,6 @@ export class Notification implements INotification {
* @returns { TNotification | undefined }
*/
markNotificationAsRead = async (workspaceSlug: string): Promise<TNotification | undefined> => {
if (!this.id) return undefined;
const currentNotificationReadAt = this.read_at;
try {
const payload: Partial<TNotification> = {
@ -215,8 +211,6 @@ export class Notification implements INotification {
* @returns { TNotification | undefined }
*/
markNotificationAsUnRead = async (workspaceSlug: string): Promise<TNotification | undefined> => {
if (!this.id) return undefined;
const currentNotificationReadAt = this.read_at;
try {
const payload: Partial<TNotification> = {
@ -242,8 +236,6 @@ export class Notification implements INotification {
* @returns { TNotification | undefined }
*/
archiveNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
if (!this.id) return undefined;
const currentNotificationArchivedAt = this.archived_at;
try {
const payload: Partial<TNotification> = {
@ -267,8 +259,6 @@ export class Notification implements INotification {
* @returns { TNotification | undefined }
*/
unArchiveNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
if (!this.id) return undefined;
const currentNotificationArchivedAt = this.archived_at;
try {
const payload: Partial<TNotification> = {
@ -293,8 +283,6 @@ export class Notification implements INotification {
* @returns { TNotification | undefined }
*/
snoozeNotification = async (workspaceSlug: string, snoozeTill: Date): Promise<TNotification | undefined> => {
if (!this.id) return undefined;
const currentNotificationSnoozeTill = this.snoozed_till;
try {
const payload: Partial<TNotification> = {
@ -315,8 +303,6 @@ export class Notification implements INotification {
* @returns { TNotification | undefined }
*/
unSnoozeNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
if (!this.id) return undefined;
const currentNotificationSnoozeTill = this.snoozed_till;
try {
const payload: Partial<TNotification> = {