mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
merge
This commit is contained in:
@@ -13,6 +13,7 @@ const object = [
|
||||
'diplomas',
|
||||
'expedientes-pr',
|
||||
'despachos',
|
||||
'*',
|
||||
] as const;
|
||||
|
||||
export type IdObject = typeof object[number];
|
||||
export type notificationObject = typeof object[number];
|
||||
@@ -15,7 +15,7 @@ import { v4 as uuidv4 } from 'uuid';
|
||||
import { EventTrigger } from '../services/eventTrigger.service';
|
||||
import { SessionStore } from '../store/session.service';
|
||||
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
|
||||
import { IdObject } from '../models/notifications';
|
||||
import { notificationObject } from '../models/notifications';
|
||||
/* import { Events } from 'ionic-angular' */
|
||||
|
||||
@Injectable({
|
||||
@@ -28,7 +28,7 @@ export class NotificationsService {
|
||||
DataArray = new Array();
|
||||
|
||||
callbacks: {
|
||||
type: string,
|
||||
type: notificationObject,
|
||||
funx: Function
|
||||
id: string
|
||||
}[] = []
|
||||
@@ -52,7 +52,7 @@ export class NotificationsService {
|
||||
/* private fcm: FCM */) {
|
||||
|
||||
}
|
||||
registerCallback(type: IdObject, funx: Function, object: any = {}) {
|
||||
registerCallback(type: notificationObject, funx: Function, object: any = {}) {
|
||||
|
||||
const id = uuidv4()
|
||||
this.callbacks.push({ type, funx, id })
|
||||
@@ -63,6 +63,27 @@ export class NotificationsService {
|
||||
return id;
|
||||
}
|
||||
|
||||
// registerCallback({type, funx, id = uuidv4()}:{
|
||||
// type: notificationObject,
|
||||
// funx: Function
|
||||
// id?: string
|
||||
// }) {
|
||||
|
||||
// this.callbacks.push({ type, funx, id })
|
||||
|
||||
// return id;
|
||||
// }
|
||||
|
||||
private runNotificationCallback(notification) {
|
||||
this.callbacks.forEach((data) => {
|
||||
if(data.type == notification.data.IdObject) {
|
||||
data.funx({notification})
|
||||
} else if (data.type == '*') {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
deleteCallback(id) {
|
||||
this.callbacks.forEach((e, index) => {
|
||||
if (e.id == id) {
|
||||
@@ -155,6 +176,7 @@ export class NotificationsService {
|
||||
}
|
||||
})
|
||||
|
||||
this.runNotificationCallback(notification)
|
||||
/* this.eventTriger.publish('notificatioRecive') */
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
@@ -174,6 +196,7 @@ export class NotificationsService {
|
||||
notification: "recive"
|
||||
}) */
|
||||
this.notificatinsRoutes(notification)
|
||||
this.runNotificationCallback(notification)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user