@po-ui/ng-sync 15.1.1 → 15.2.0

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,13 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, NgModule } from '@angular/core';
3
3
  import { StatusCodes } from 'http-status-codes';
4
- import { Subject, Observable, of, merge, fromEvent, forkJoin, timer } from 'rxjs';
5
- import { map, expand, reduce, mapTo, mergeMap } from 'rxjs/operators';
4
+ import { Subject, Observable, of, forkJoin, timer } from 'rxjs';
5
+ import { map, expand, reduce, mergeMap } from 'rxjs/operators';
6
6
  import * as i1 from '@po-ui/ng-storage';
7
7
  import * as i1$1 from '@angular/common/http';
8
8
  import { HttpHeaders } from '@angular/common/http';
9
- import * as i1$2 from '@awesome-cordova-plugins/network/ngx';
10
- import { Network } from '@awesome-cordova-plugins/network/ngx';
9
+ import { Network } from '@capacitor/network';
11
10
 
12
11
  /**
13
12
  * @description
@@ -1617,8 +1616,8 @@ class PoNetworkStatus {
1617
1616
  * O `PoNetworkService` é utilizado para verificar o status e o tipo da conexão de rede do dispositivo.
1618
1617
  */
1619
1618
  class PoNetworkService {
1620
- constructor(network) {
1621
- this.initNetwork(network);
1619
+ constructor() {
1620
+ this.initNetwork();
1622
1621
  }
1623
1622
  /**
1624
1623
  * Retorna as propriedades tipo e status da conexão do dispositivo no momento da chamada.
@@ -1638,30 +1637,29 @@ class PoNetworkService {
1638
1637
  onChange() {
1639
1638
  return this.networkTypeNow.asObservable();
1640
1639
  }
1641
- getNavigatorStatus() {
1642
- return merge(fromEvent(window, 'offline').pipe(mapTo(false)), fromEvent(window, 'online').pipe(mapTo(true)), Observable.create(sub => {
1643
- sub.next(navigator.onLine);
1644
- sub.complete();
1645
- }));
1646
- }
1647
- initNetwork(network) {
1640
+ initNetwork() {
1648
1641
  this.networkTypeNow = new Subject();
1649
- this.initSubscriber(network);
1650
- }
1651
- initSubscriber(network) {
1652
- if (network) {
1653
- this.getNavigatorStatus().subscribe(status => {
1654
- this.networkType = network.type;
1655
- this.networkTypeNow.next({ status: status, type: this.networkType });
1656
- });
1657
- }
1642
+ this.initSubscriber();
1643
+ }
1644
+ async getStatus() {
1645
+ return await Network.getStatus();
1646
+ }
1647
+ async initSubscriber() {
1648
+ const networkStatus = await this.getStatus();
1649
+ this.networkType = networkStatus.connected ? networkStatus.connectionType : 'none';
1650
+ this.networkTypeNow.next({ status: networkStatus.connected, type: this.networkType });
1651
+ /* istanbul ignore next */
1652
+ Network.addListener('networkStatusChange', status => {
1653
+ this.networkType = status.connected ? status.connectionType : 'none';
1654
+ this.networkTypeNow.next({ status: status.connected, type: this.networkType });
1655
+ });
1658
1656
  }
1659
1657
  }
1660
- PoNetworkService.ɵfac = function PoNetworkService_Factory(t) { return new (t || PoNetworkService)(i0.ɵɵinject(i1$2.Network)); };
1658
+ PoNetworkService.ɵfac = function PoNetworkService_Factory(t) { return new (t || PoNetworkService)(); };
1661
1659
  PoNetworkService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PoNetworkService, factory: PoNetworkService.ɵfac });
1662
1660
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PoNetworkService, [{
1663
1661
  type: Injectable
1664
- }], function () { return [{ type: i1$2.Network }]; }, null); })();
1662
+ }], function () { return []; }, null); })();
1665
1663
 
1666
1664
  /**
1667
1665
  * @description
@@ -1990,8 +1988,7 @@ PoSyncModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ providers: [
1990
1988
  PoSchemaDefinitionService,
1991
1989
  PoSchemaService,
1992
1990
  PoSyncService,
1993
- PoHttpClientService,
1994
- Network
1991
+ PoHttpClientService
1995
1992
  ] });
1996
1993
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PoSyncModule, [{
1997
1994
  type: NgModule,
@@ -2002,8 +1999,7 @@ PoSyncModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ providers: [
2002
1999
  PoSchemaDefinitionService,
2003
2000
  PoSchemaService,
2004
2001
  PoSyncService,
2005
- PoHttpClientService,
2006
- Network
2002
+ PoHttpClientService
2007
2003
  ],
2008
2004
  imports: []
2009
2005
  }]