notification and chat slow

This commit is contained in:
Peter Maquiran
2024-12-16 12:04:02 +01:00
parent aef73625f0
commit 18a8d90d99
60 changed files with 363 additions and 381 deletions
@@ -21,7 +21,7 @@ export function NotificationListChanges(
const localItem = localMap.get(id);
if (!localItem) {
changes.insert.push(serverItem);
} else if (localItem.status !== serverItem.status) {
} else if (localItem.viewDate !== serverItem.viewDate) {
changes.update.push(serverItem);
}
}
@@ -122,7 +122,7 @@ export class LocalNotificationService {
return from(liveQuery( () => {
return NotificationDataSource.notification.orderBy('createdAt').reverse().toArray()
.then(notifications => {
return notifications.filter(notification => notification.status === false)
return notifications.filter(notification => notification.viewDate == null)
})
}))
}
@@ -132,7 +132,7 @@ export class LocalNotificationService {
return NotificationDataSource.notification
.toArray()
.then(notifications => {
return notifications.filter(notification => notification.status === false).length
return notifications.filter(notification => notification.viewDate == null).length
})
}))
}
@@ -22,7 +22,7 @@ export class RemoteNotificationService {
}
async notificationStatus(id: string) {
async notificationStatus(id: number) {
return await this.httpService.patch<NotificationOutputDTO>(`${this.baseUrl}/Notifications/${id}/status`);
}
@@ -30,5 +30,4 @@ export class RemoteNotificationService {
async notificationDeleteAll(userId: any) {
return await this.httpService.delete<NotificationOutputDTO>(`${this.baseUrl}/Notifications/${userId}`);
}
}
@@ -8,7 +8,7 @@ export const NotificationOutputDTOSchema = z.object({
total: z.number(),
result: z.array(
z.object({
id: z.string(),
id: z.number(),
service: z.string(),
title: z.string(),
body: z.string(),
@@ -17,7 +17,6 @@ export const NotificationOutputDTOSchema = z.object({
folderId: z.string().nullable(),
createdAt: z.string(),
viewDate: z.string().nullable(),
status: z.boolean(),
startDate: z.string().nullable(),
endDate: z.string().nullable(),
bodyEvent: z.string().nullable(),
@@ -2,16 +2,16 @@ import { Dexie, EntityTable, liveQuery } from 'Dexie';
import { z } from 'zod';
export const NotificationTableSchema = z.object({
notificationId: z.string().nullable(),
notificationId: z.number().nullable(),
title: z.string().optional().nullable(),
service: z.string().nullable(),
object: z.string().optional().nullable(),
idObject: z.string().nullable(),
viewDate: z.string().nullable(),
folderId: z.string().optional().nullable(),
dateInit: z.string().optional().nullable(),
dateEnd: z.string().optional().nullable(),
location: z.string().optional().nullable(),
status: z.boolean().optional(),
notificationBody: z.any().optional()
})
export type NotificationTable = z.infer<typeof NotificationTableSchema>
@@ -83,7 +83,7 @@ export class NotificationRepositoryService {
async notificationStatus(item: NotificationTable) {
await this.RemoteNotificationService.notificationStatus(item.notificationId)
item.status = true
item.viewDate = new Date().toUTCString()
this.LocalNotificationService.updateNotification(item)
this
this.init()
@@ -93,14 +93,14 @@ export class NotificationRepositoryService {
async RemoveNotificationStatus(item: NotificationTable) {
await this.RemoteNotificationService.notificationStatus(item.notificationId)
item.status = true
item.viewDate = new Date().toUTCString()
this.LocalNotificationService.updateNotification(item)
this.init()
return
}
async localNotificationStatus(item: NotificationTable) {
item.status = true
item.viewDate = new Date().toUTCString()
this.LocalNotificationService.updateNotification(item)
this.init()
return
@@ -14,9 +14,9 @@ export function NotificationListMapper(NotificationOutputDTO: NotificationOutput
dateInit: e.startDate,
dateEnd: e.endDate,
createdAt: e.createdAt,
status: e.status,
location: e.location,
notificationBody: e.body
notificationBody: e.body,
viewDate: e.viewDate
}
))
}
@@ -11,8 +11,8 @@ export class NotificationService {
) { }
deleteAllNotificationByUserId(userId: INotificationDeleteAllByUserId) {
this.NotificationDeleteAllServiceUseCase.execute(userId)
deleteAllNotificationByUserId() {
return this.NotificationDeleteAllServiceUseCase.execute()
}