Fix create event

This commit is contained in:
Peter Maquiran
2021-09-03 12:19:21 +01:00
parent 5d4a238a57
commit 745b634123
30 changed files with 125 additions and 724 deletions
+22 -8
View File
@@ -14,7 +14,7 @@ import { ToastService } from '../services/toast.service';
import { Optional } from '@angular/core';
import { JsonStore } from './jsonStore.service';
import { synchro } from './socket/synchro.service';
import { v4 as uuidv4 } from 'uuid'
@Injectable({
providedIn: 'root'
})
@@ -27,10 +27,11 @@ export class NotificationsService {
callbacks: {
type: string,
funx: Function
id: string
}[] = []
constructor(
private http: HttpClient,
private http: HttpClient,
private storageService: StorageService,
private modalController: ModalController,
public modalCtrl: AlertController,
@@ -51,15 +52,28 @@ export class NotificationsService {
}
registerCallback(type: string, funx: Function, object: any = {} ) {
registerCallback(type: string, funx: Function, object: any = {} ) {
this.callbacks.push({type, funx})
if(!object.hasOwnProperty('desktop') && object['desktop'] != false) {
synchro.registerCallback('Notification',funx, type)
}
const id = uuidv4()
this.callbacks.push({type, funx, id})
if(!object.hasOwnProperty('desktop') && object['desktop'] != false) {
synchro.registerCallback('Notification',funx, type)
}
return id;
}
deleteCallback(id) {
this.callbacks.forEach((e, index)=>{
if(e.id == id) {
if (index > -1) {
this.callbacks.splice(index, 1);
}
}
})
}
getTokenByUserIdAndId(user, userID) {
const geturl = environment.apiURL + 'notifications/user/' + userID;