eventtrigger created for notifications

This commit is contained in:
Eudes Inácio
2021-09-21 06:08:01 +01:00
parent 3c78c5ddc4
commit 7fdb16c272
4 changed files with 56 additions and 3 deletions
+6
View File
@@ -11,6 +11,7 @@ import { JsonStore } from '../../services/jsonStore.service';
import { StorageService } from '../../services/storage.service';
import { NotificationsService } from '../../services/notifications.service';
import { SessionStore } from 'src/app/store/session.service';
import { EventTrigger } from '../../services/eventTrigger.service';
@Component({
selector: 'app-profile',
@@ -43,6 +44,7 @@ export class ProfilePage implements OnInit {
private notificationservice: NotificationsService,
private platform: Platform,
private notificationsService: NotificationsService,
private eventtrigger: EventTrigger
) {
this.loggeduser = authService.ValidatedUser;
@@ -200,6 +202,10 @@ export class ProfilePage implements OnInit {
this.notificationservice.tempClearArray();
this.deleteNotification(index);
this.eventtrigger.publishSomeData({
notification: "deleted"
})
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { EventTrigger } from './eventTrigger.service';
describe('EventsService', () => {
let service: EventTrigger;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(EventTrigger);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+21
View File
@@ -0,0 +1,21 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class EventTrigger {
private eventSubject = new Subject<any>()
publishSomeData(data: any){
this.eventSubject.next(data)
}
getObservable(): Subject<any>{
return this.eventSubject
}
}
+13 -3
View File
@@ -8,6 +8,7 @@ import { StorageService } from '../../services/storage.service';
import { SessionStore } from 'src/app/store/session.service';
import { NotificationsService } from '../../services/notifications.service';
import { environment } from 'src/environments/environment';
import { EventTrigger } from '../../services/eventTrigger.service';
@Component({
selector: 'app-header',
@@ -33,7 +34,8 @@ export class HeaderPage implements OnInit {
private animationController: AnimationController,
private storageservice: StorageService,
private platform: Platform,
private notificationsService: NotificationsService,
private notificationsService: NotificationsService,
private eventrigger: EventTrigger
) {
this.loggeduser = SessionStore.user;
router.events.subscribe((val) => {
@@ -46,12 +48,20 @@ export class HeaderPage implements OnInit {
this.hideSearch();
this.notificationLengthData();
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
/* if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log('Notifications not supported')
this.UpdateNotificationCount();
} else {
this.UpdateNotificationCount();
}
} */
this.eventrigger.getObservable().subscribe((data)=>{
if(data.notification == "delete" || "recive"){
this.notificationLengthData();
console.log('Deleted notification',data )
}
})
}