[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
|
|
@ -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> = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue