@vgroup/dialbox 0.0.62 → 0.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, EventEmitter, Component, Input, Output, ViewChild, Inject, NgModule } from '@angular/core';
2
+ import { Injectable, EventEmitter, Component, Input, Output, ViewChild, Inject, PLATFORM_ID, APP_INITIALIZER, Injector, NgModule } from '@angular/core';
3
3
  import swal from 'sweetalert2';
4
4
  import { AsYouType } from 'libphonenumber-js';
5
5
  import { throwError, BehaviorSubject, interval, Subscription } from 'rxjs';
@@ -12,7 +12,7 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog';
12
12
  import * as i5 from '@angular/router';
13
13
  import { RouterLink, RouterModule } from '@angular/router';
14
14
  import * as i4 from '@angular/common';
15
- import { CommonModule } from '@angular/common';
15
+ import { isPlatformBrowser, CommonModule } from '@angular/common';
16
16
  import * as i3 from '@angular/forms';
17
17
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
18
18
  import { BrowserModule } from '@angular/platform-browser';
@@ -3176,6 +3176,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
3176
3176
  args: [MAT_DIALOG_DATA]
3177
3177
  }] }]; } });
3178
3178
 
3179
+ class AppInitializerService {
3180
+ constructor(twilioService, extensionService, router, platformId) {
3181
+ this.twilioService = twilioService;
3182
+ this.extensionService = extensionService;
3183
+ this.router = router;
3184
+ this.platformId = platformId;
3185
+ }
3186
+ initializeApp() {
3187
+ return new Promise((resolve) => {
3188
+ if (isPlatformBrowser(this.platformId)) {
3189
+ this.initializeServices().then(() => {
3190
+ resolve();
3191
+ });
3192
+ }
3193
+ else {
3194
+ resolve();
3195
+ }
3196
+ });
3197
+ }
3198
+ async initializeServices() {
3199
+ try {
3200
+ // Initialize Twilio device
3201
+ await this.initializeTwilio();
3202
+ // Fetch initial data
3203
+ await this.fetchInitialData();
3204
+ console.log('App initialization complete');
3205
+ }
3206
+ catch (error) {
3207
+ console.error('Error during app initialization:', error);
3208
+ }
3209
+ }
3210
+ async initializeTwilio() {
3211
+ const token = localStorage.getItem('ext_token');
3212
+ if (token) {
3213
+ await this.twilioService.initializeTwilioDevice();
3214
+ }
3215
+ }
3216
+ async fetchInitialData() {
3217
+ const token = localStorage.getItem('ext_token');
3218
+ if (token) {
3219
+ try {
3220
+ // Fetch caller ID
3221
+ const response = await this.extensionService.fetchCallerId(token).toPromise();
3222
+ if (response && typeof response === 'object' && 'status' in response) {
3223
+ const callerIdRes = response;
3224
+ if (callerIdRes.status === 200) {
3225
+ const callerId = callerIdRes.callerid || 'Not set';
3226
+ localStorage.setItem('callerID', callerId);
3227
+ this.extensionService.changeMessage(callerId);
3228
+ }
3229
+ }
3230
+ }
3231
+ catch (error) {
3232
+ console.error('Error fetching initial data:', error);
3233
+ }
3234
+ }
3235
+ }
3236
+ }
3237
+ AppInitializerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: AppInitializerService, deps: [{ token: TwilioService }, { token: ExtensionService }, { token: i5.Router }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
3238
+ AppInitializerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: AppInitializerService, providedIn: 'root' });
3239
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: AppInitializerService, decorators: [{
3240
+ type: Injectable,
3241
+ args: [{
3242
+ providedIn: 'root'
3243
+ }]
3244
+ }], ctorParameters: function () { return [{ type: TwilioService }, { type: ExtensionService }, { type: i5.Router }, { type: Object, decorators: [{
3245
+ type: Inject,
3246
+ args: [PLATFORM_ID]
3247
+ }] }]; } });
3248
+
3179
3249
  class DialboxModule {
3180
3250
  }
3181
3251
  DialboxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DialboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -3192,7 +3262,19 @@ DialboxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
3192
3262
  IncomingCallComponent,
3193
3263
  CallProgressComponent,
3194
3264
  CallerIdDialogComponent] });
3195
- DialboxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DialboxModule, imports: [CommonModule,
3265
+ DialboxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DialboxModule, providers: [
3266
+ {
3267
+ provide: APP_INITIALIZER,
3268
+ useFactory: (injector) => {
3269
+ return () => {
3270
+ const appInitializer = injector.get(AppInitializerService);
3271
+ return appInitializer.initializeApp();
3272
+ };
3273
+ },
3274
+ deps: [Injector],
3275
+ multi: true
3276
+ }
3277
+ ], imports: [CommonModule,
3196
3278
  FormsModule,
3197
3279
  ReactiveFormsModule,
3198
3280
  HttpClientModule,
@@ -3221,6 +3303,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
3221
3303
  IncomingCallComponent,
3222
3304
  CallProgressComponent,
3223
3305
  CallerIdDialogComponent,
3306
+ ],
3307
+ providers: [
3308
+ {
3309
+ provide: APP_INITIALIZER,
3310
+ useFactory: (injector) => {
3311
+ return () => {
3312
+ const appInitializer = injector.get(AppInitializerService);
3313
+ return appInitializer.initializeApp();
3314
+ };
3315
+ },
3316
+ deps: [Injector],
3317
+ multi: true
3318
+ }
3224
3319
  ]
3225
3320
  }]
3226
3321
  }] });