|
@@ -22,6 +22,7 @@ import { PushNotificationDecorator as LeavePushNotif } from 'fis/leave/decorator
|
|
|
import { FISMessaging } from 'fis/index';
|
|
import { FISMessaging } from 'fis/index';
|
|
|
import { BusinessDataModule } from 'fis/business.data/business.data.module';
|
|
import { BusinessDataModule } from 'fis/business.data/business.data.module';
|
|
|
import { NotificationService } from 'angularlib/notification/notification.service';
|
|
import { NotificationService } from 'angularlib/notification/notification.service';
|
|
|
|
|
+import { DecoratorSubject } from 'fis-commons/decorator';
|
|
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
|
selector: 'app-root',
|
|
selector: 'app-root',
|
|
@@ -107,23 +108,7 @@ export class AppComponent extends BaseComponent implements OnInit {
|
|
|
this.pbTitle.setTitle(this.title);
|
|
this.pbTitle.setTitle(this.title);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- /**subsribe user changes and initiate timeout timer */
|
|
|
|
|
- this.loginService.user$.pipe(untilDestroy(this)).subscribe((user:any) => {
|
|
|
|
|
- if (user?.fisInfo) {
|
|
|
|
|
- this.timeout.pipe(untilDestroy(this),takeUntil(this.loginService.loggedOut)).subscribe();
|
|
|
|
|
- if (this.leavePushNotif$ === undefined) {
|
|
|
|
|
- this.leavePushNotif$ = new LeavePushNotif(
|
|
|
|
|
- this,
|
|
|
|
|
- this.loginService,
|
|
|
|
|
- this.messaging,
|
|
|
|
|
- this.notification
|
|
|
|
|
- ).subscribe();
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- if (this.leavePushNotif$) this.leavePushNotif$.unsubscribe();
|
|
|
|
|
- this.leavePushNotif$ = undefined;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
this.store.select(NOTIFICATION_STATE_TOKEN).pipe(untilDestroy(this)).subscribe({
|
|
this.store.select(NOTIFICATION_STATE_TOKEN).pipe(untilDestroy(this)).subscribe({
|
|
|
next: (state:any) => {
|
|
next: (state:any) => {
|
|
@@ -136,6 +121,14 @@ export class AppComponent extends BaseComponent implements OnInit {
|
|
|
if (this.platform.ANDROID || this.platform.IOS) this.pwaPrompt();
|
|
if (this.platform.ANDROID || this.platform.IOS) this.pwaPrompt();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ ngAfterViewInit() {
|
|
|
|
|
+ /**subsribe user changes and initiate timeout timer */
|
|
|
|
|
+ this.loginService.user$.pipe(untilDestroy(this)).subscribe((user:any) => {
|
|
|
|
|
+ if (user) this.timeout.pipe(untilDestroy(this),takeUntil(this.loginService.loggedOut)).subscribe();
|
|
|
|
|
+ this.subscribePushNotifications();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* change application language
|
|
* change application language
|
|
|
* @param {string} language
|
|
* @param {string} language
|
|
@@ -179,4 +172,20 @@ export class AppComponent extends BaseComponent implements OnInit {
|
|
|
disableInAppInstallPrompt();
|
|
disableInAppInstallPrompt();
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private subscribePushNotifications() {
|
|
|
|
|
+ if (this.loginService.user?.fisInfo) {
|
|
|
|
|
+ if (this.leavePushNotif$ === undefined) {
|
|
|
|
|
+ this.leavePushNotif$ = new LeavePushNotif(
|
|
|
|
|
+ this,
|
|
|
|
|
+ this.loginService,
|
|
|
|
|
+ this.messaging,
|
|
|
|
|
+ this.notification
|
|
|
|
|
+ ).subscribe();
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (this.leavePushNotif$) this.leavePushNotif$.unsubscribe();
|
|
|
|
|
+ this.leavePushNotif$ = undefined;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|