add event driven

This commit is contained in:
Peter Maquiran
2023-01-16 14:17:06 +01:00
parent e24f4010e0
commit d43ce7fe09
4 changed files with 36 additions and 11 deletions
+2 -1
View File
@@ -14,7 +14,8 @@
"dev:share": "lite-server --baseDir=share",
"install:chromium": "node node_modules/puppeteer/install.js",
"build:version": "node ./version/git-version.js",
"ionic-build": "ionic cap run android --prod"
"ionic-build": "ionic cap run android --prod",
"prepare": "husky install"
},
"private": true,
"dependencies": {
+2 -1
View File
@@ -13,6 +13,7 @@ const object = [
'diplomas',
'expedientes-pr',
'despachos',
'*',
] as const;
export type IdObject = typeof object[number];
export type notificationObject = typeof object[number];
+26 -3
View File
@@ -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)
}
);
}
+6 -6
View File
@@ -1,12 +1,12 @@
export let versionData = {
"shortSHA": "7fbe4abdd",
"SHA": "7fbe4abddf5aadf72d781e9c140f6364b5f164e3",
"shortSHA": "e24f4010e",
"SHA": "e24f4010e0b8d94a232bf8d2f5ba88c6fe8d6256",
"branch": "feature/ios-ui-fix",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Mon Jan 16 09:06:12 2023 +0100'",
"lastCommitMessage": "save",
"lastCommitNumber": "4626",
"lastCommitTime": "'Mon Jan 16 12:08:38 2023 +0100'",
"lastCommitMessage": "fix notification",
"lastCommitNumber": "4627",
"change": "",
"changeStatus": "On branch feature/ios-ui-fix\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: .gitignore\n\tnew file: android/app/google-services.json",
"changeStatus": "On branch feature/ios-ui-fix\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: package.json\n\tmodified: src/app/models/notifications.ts\n\tmodified: src/app/services/notifications.service.ts",
"changeAuthor": "peter.maquiran"
}