[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:
parent
d0f3987aeb
commit
134644fdf1
8 changed files with 8 additions and 21 deletions
|
|
@ -35,7 +35,7 @@ export type TNotificationData = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TNotification = {
|
export type TNotification = {
|
||||||
id: string | undefined;
|
id: string;
|
||||||
title: string | undefined;
|
title: string | undefined;
|
||||||
data: TNotificationData | undefined;
|
data: TNotificationData | undefined;
|
||||||
entity_identifier: string | undefined;
|
entity_identifier: string | undefined;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { NotificationsSidebarRoot } from "@/plane-web/components/workspace-notifications";
|
import { NotificationsSidebarRoot } from "@/components/workspace-notifications";
|
||||||
|
|
||||||
export default function ProjectInboxIssuesLayout({ children }: { children: React.ReactNode }) {
|
export default function ProjectInboxIssuesLayout({ children }: { children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export * from './root'
|
export * from "./notification-card/root";
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
export * from "./notification-app-sidebar-option";
|
export * from "./notification-app-sidebar-option";
|
||||||
export * from "./sidebar";
|
export * from "./sidebar";
|
||||||
|
export * from "./root";
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import {
|
||||||
NotificationEmptyState,
|
NotificationEmptyState,
|
||||||
NotificationSidebarHeader,
|
NotificationSidebarHeader,
|
||||||
AppliedFilters,
|
AppliedFilters,
|
||||||
NotificationCardListRoot,
|
|
||||||
} from "@/components/workspace-notifications";
|
} from "@/components/workspace-notifications";
|
||||||
// constants
|
// constants
|
||||||
import { NOTIFICATION_TABS, TNotificationTab } from "@/constants/notification";
|
import { NOTIFICATION_TABS, TNotificationTab } from "@/constants/notification";
|
||||||
|
|
@ -21,6 +20,8 @@ import { getNumberCount } from "@/helpers/string.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { useWorkspace, useWorkspaceNotifications } from "@/hooks/store";
|
import { useWorkspace, useWorkspaceNotifications } from "@/hooks/store";
|
||||||
|
|
||||||
|
import { NotificationCardListRoot } from "@/plane-web/components/workspace-notifications";
|
||||||
|
|
||||||
export const NotificationsSidebarRoot: FC = observer(() => {
|
export const NotificationsSidebarRoot: FC = observer(() => {
|
||||||
const { workspaceSlug } = useParams();
|
const { workspaceSlug } = useParams();
|
||||||
// hooks
|
// hooks
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
export * from "./root";
|
|
||||||
export * from "./item";
|
export * from "./item";
|
||||||
export * from "./options";
|
export * from "./options";
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export interface INotification extends TNotification {
|
||||||
|
|
||||||
export class Notification implements INotification {
|
export class Notification implements INotification {
|
||||||
// observables
|
// observables
|
||||||
id: string | undefined = undefined;
|
id: string;
|
||||||
title: string | undefined = undefined;
|
title: string | undefined = undefined;
|
||||||
data: TNotificationData | undefined = undefined;
|
data: TNotificationData | undefined = undefined;
|
||||||
entity_identifier: string | undefined = undefined;
|
entity_identifier: string | undefined = undefined;
|
||||||
|
|
@ -54,6 +54,7 @@ export class Notification implements INotification {
|
||||||
private store: CoreRootStore,
|
private store: CoreRootStore,
|
||||||
private notification: TNotification
|
private notification: TNotification
|
||||||
) {
|
) {
|
||||||
|
this.id = this.notification.id;
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
// observables
|
// observables
|
||||||
id: observable.ref,
|
id: observable.ref,
|
||||||
|
|
@ -90,7 +91,6 @@ export class Notification implements INotification {
|
||||||
snoozeNotification: action,
|
snoozeNotification: action,
|
||||||
unSnoozeNotification: action,
|
unSnoozeNotification: action,
|
||||||
});
|
});
|
||||||
this.id = this.notification.id;
|
|
||||||
this.title = this.notification.title;
|
this.title = this.notification.title;
|
||||||
this.data = this.notification.data;
|
this.data = this.notification.data;
|
||||||
this.entity_identifier = this.notification.entity_identifier;
|
this.entity_identifier = this.notification.entity_identifier;
|
||||||
|
|
@ -169,8 +169,6 @@ export class Notification implements INotification {
|
||||||
workspaceSlug: string,
|
workspaceSlug: string,
|
||||||
payload: Partial<TNotification>
|
payload: Partial<TNotification>
|
||||||
): Promise<TNotification | undefined> => {
|
): Promise<TNotification | undefined> => {
|
||||||
if (!this.id) return undefined;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const notification = await workspaceNotificationService.updateNotificationById(workspaceSlug, this.id, payload);
|
const notification = await workspaceNotificationService.updateNotificationById(workspaceSlug, this.id, payload);
|
||||||
if (notification) {
|
if (notification) {
|
||||||
|
|
@ -188,8 +186,6 @@ export class Notification implements INotification {
|
||||||
* @returns { TNotification | undefined }
|
* @returns { TNotification | undefined }
|
||||||
*/
|
*/
|
||||||
markNotificationAsRead = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
markNotificationAsRead = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
||||||
if (!this.id) return undefined;
|
|
||||||
|
|
||||||
const currentNotificationReadAt = this.read_at;
|
const currentNotificationReadAt = this.read_at;
|
||||||
try {
|
try {
|
||||||
const payload: Partial<TNotification> = {
|
const payload: Partial<TNotification> = {
|
||||||
|
|
@ -215,8 +211,6 @@ export class Notification implements INotification {
|
||||||
* @returns { TNotification | undefined }
|
* @returns { TNotification | undefined }
|
||||||
*/
|
*/
|
||||||
markNotificationAsUnRead = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
markNotificationAsUnRead = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
||||||
if (!this.id) return undefined;
|
|
||||||
|
|
||||||
const currentNotificationReadAt = this.read_at;
|
const currentNotificationReadAt = this.read_at;
|
||||||
try {
|
try {
|
||||||
const payload: Partial<TNotification> = {
|
const payload: Partial<TNotification> = {
|
||||||
|
|
@ -242,8 +236,6 @@ export class Notification implements INotification {
|
||||||
* @returns { TNotification | undefined }
|
* @returns { TNotification | undefined }
|
||||||
*/
|
*/
|
||||||
archiveNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
archiveNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
||||||
if (!this.id) return undefined;
|
|
||||||
|
|
||||||
const currentNotificationArchivedAt = this.archived_at;
|
const currentNotificationArchivedAt = this.archived_at;
|
||||||
try {
|
try {
|
||||||
const payload: Partial<TNotification> = {
|
const payload: Partial<TNotification> = {
|
||||||
|
|
@ -267,8 +259,6 @@ export class Notification implements INotification {
|
||||||
* @returns { TNotification | undefined }
|
* @returns { TNotification | undefined }
|
||||||
*/
|
*/
|
||||||
unArchiveNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
unArchiveNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
||||||
if (!this.id) return undefined;
|
|
||||||
|
|
||||||
const currentNotificationArchivedAt = this.archived_at;
|
const currentNotificationArchivedAt = this.archived_at;
|
||||||
try {
|
try {
|
||||||
const payload: Partial<TNotification> = {
|
const payload: Partial<TNotification> = {
|
||||||
|
|
@ -293,8 +283,6 @@ export class Notification implements INotification {
|
||||||
* @returns { TNotification | undefined }
|
* @returns { TNotification | undefined }
|
||||||
*/
|
*/
|
||||||
snoozeNotification = async (workspaceSlug: string, snoozeTill: Date): Promise<TNotification | undefined> => {
|
snoozeNotification = async (workspaceSlug: string, snoozeTill: Date): Promise<TNotification | undefined> => {
|
||||||
if (!this.id) return undefined;
|
|
||||||
|
|
||||||
const currentNotificationSnoozeTill = this.snoozed_till;
|
const currentNotificationSnoozeTill = this.snoozed_till;
|
||||||
try {
|
try {
|
||||||
const payload: Partial<TNotification> = {
|
const payload: Partial<TNotification> = {
|
||||||
|
|
@ -315,8 +303,6 @@ export class Notification implements INotification {
|
||||||
* @returns { TNotification | undefined }
|
* @returns { TNotification | undefined }
|
||||||
*/
|
*/
|
||||||
unSnoozeNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
unSnoozeNotification = async (workspaceSlug: string): Promise<TNotification | undefined> => {
|
||||||
if (!this.id) return undefined;
|
|
||||||
|
|
||||||
const currentNotificationSnoozeTill = this.snoozed_till;
|
const currentNotificationSnoozeTill = this.snoozed_till;
|
||||||
try {
|
try {
|
||||||
const payload: Partial<TNotification> = {
|
const payload: Partial<TNotification> = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue