mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
eventtrigger created for notifications
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 )
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user