mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix chat open modal
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Injectable, NgZone } from '@angular/core';
|
||||
import { StorageService } from '../services/storage.service';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { SHA1 } from 'crypto-js';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -40,17 +41,13 @@ export class NotificationHolderService {
|
||||
this.storageService.store("Notifications", this._notificationList)
|
||||
}
|
||||
|
||||
addNotification(notification) {
|
||||
|
||||
notificationObject(notification) {
|
||||
const element = notification
|
||||
const i = this._notificationList.length + 1
|
||||
|
||||
let notificationObject;
|
||||
if (element.notification) {
|
||||
|
||||
notificationObject = {
|
||||
id: notification?.id || uuidv4(),
|
||||
index: i,
|
||||
id: notification?.id,
|
||||
title: element.notification.title,
|
||||
Service: element.data.Service,
|
||||
Object: element.data.Object,
|
||||
@@ -68,8 +65,7 @@ export class NotificationHolderService {
|
||||
|
||||
} else if (element.data) {
|
||||
notificationObject = {
|
||||
id: notification?.id || uuidv4(),
|
||||
index: i,
|
||||
id: notification?.id,
|
||||
title: element.title,
|
||||
Service: element.data.Service,
|
||||
Object: element.data.Object,
|
||||
@@ -88,25 +84,38 @@ export class NotificationHolderService {
|
||||
} else {
|
||||
{
|
||||
notificationObject = {
|
||||
id: notification?.id || uuidv4(),
|
||||
FolderId: element.FolderId,
|
||||
IdObject: element.IdObject,
|
||||
Location: element.Location,
|
||||
Object: element.Object,
|
||||
Role: element.Role,
|
||||
Service: element.Service,
|
||||
Status: element.Status,
|
||||
TypeAgenda: element.TypeAgenda,
|
||||
body: element.body,
|
||||
dateEnd: element.dateEnd,
|
||||
dateInit: element.dateInit,
|
||||
index: element.index,
|
||||
id: notification?.id,
|
||||
title: element.title,
|
||||
Service: element.Service,
|
||||
Object: element.Object,
|
||||
IdObject: element.IdObject,
|
||||
FolderId: element.FolderId,
|
||||
body: element.body,
|
||||
dateInit: element.dateInit,
|
||||
dateEnd: element.dateEnd,
|
||||
Location: element.Location,
|
||||
TypeAgenda: element.TypeAgenda,
|
||||
Role: element.Role,
|
||||
Status: element.Status,
|
||||
read: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notificationObject.hashCode = (SHA1(notification)).toString()
|
||||
|
||||
return notificationObject
|
||||
}
|
||||
|
||||
|
||||
|
||||
addNotification(notification) {
|
||||
|
||||
let notificationObject = this.notificationObject(notification)
|
||||
|
||||
//alert("add notification")
|
||||
//alert(JSON.stringify(notificationObject))
|
||||
|
||||
if (!this.notificationExist(notificationObject)) {
|
||||
this._notificationList.push(notificationObject)
|
||||
|
||||
@@ -115,14 +124,11 @@ export class NotificationHolderService {
|
||||
this.save()
|
||||
})
|
||||
|
||||
|
||||
} else {
|
||||
console.log('duplicate', notification, this._notificationList)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
notificationExist(notificationObject) {
|
||||
const notification = this._notificationList.find(item => {
|
||||
return item.id === notificationObject.id;
|
||||
@@ -166,4 +172,36 @@ export class NotificationHolderService {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
PhoneClickNotification(ClickedNotificationObject) {
|
||||
//alert("PhoneClickNotification")
|
||||
|
||||
//alert(JSON.stringify(ClickedNotificationObject))
|
||||
const { hashCode, id } = this.notificationObject(ClickedNotificationObject)
|
||||
|
||||
|
||||
|
||||
//alert(id)
|
||||
//alert(JSON.stringify(this._notificationList))
|
||||
// let foundNotification = this._notificationList.find( (e) => {
|
||||
// return e.hashCode == hashCode
|
||||
// })
|
||||
|
||||
//if(foundNotification) {
|
||||
// this.removeNotification(foundNotification)
|
||||
//} else {
|
||||
console.log({ ClickedNotificationObject, list: this._notificationList })
|
||||
|
||||
let foundNotification = this._notificationList.find((e) => {
|
||||
return e.id == id
|
||||
})
|
||||
|
||||
if (foundNotification) {
|
||||
this.removeNotification(foundNotification)
|
||||
} else {
|
||||
console.log({ ClickedNotificationObject, list: this._notificationList })
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user