diff --git a/.gitignore b/.gitignore index ddffe41bb..bf8107e10 100644 --- a/.gitignore +++ b/.gitignore @@ -71,4 +71,5 @@ android/app/src/main/res/** ___android/ _android/ -_www/ \ No newline at end of file +_www/ +www2020 \ No newline at end of file diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index b3e1bda3f..3c1e4ee46 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -11,10 +11,12 @@ import { PermissionService } from '../services/permission.service'; import { BackgroundService } from 'src/app/services/background.service'; import { Storage } from '@ionic/storage'; import { EventsService } from 'src/app/services/events.service'; +import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'; import { ProcessesService } from 'src/app/services/processes.service'; import { SqliteService } from 'src/app/services/sqlite.service'; import { Device } from '@capacitor/device'; import { RouteService } from 'src/app/services/route.service'; +import { NetworkServiceService, ConnectionStatus } from 'src/app/services/network-service.service'; import { NativeNotificationService } from 'src/app/services/native-notification.service'; import { UserSession } from '../models/user.model'; import { PermissionList } from '../models/permission/permissionList'; @@ -85,6 +87,8 @@ export class HomePage implements OnInit { public RouteService: RouteService, private NativeNotificationService: NativeNotificationService, private sqliteservice: SqliteService, + private RochetChatConnectorService: RochetChatConnectorService, + private NetworkServiceService: NetworkServiceService ) { if (SessionStore.exist) { this.user = SessionStore.user; @@ -139,14 +143,26 @@ export class HomePage implements OnInit { this.notificationsService.onReciveBackground(); window.addEventListener('online', () => { - // console.log('Became online') this.backgroundservice.online() if (this.platform.is('desktop') || this.platform.is('mobileweb')) { } else { this.synchWhenOnline() } - }); + + this.RochetChatConnectorService.registerCallback({ + type: 'reConnect', + funx: async () => { + this.backgroundservice.online() + } + }) + + this.NetworkServiceService.onNetworkChange().subscribe((status) => { + if(status == ConnectionStatus.Online) { + this.backgroundservice.online() + } + }) + window.addEventListener('offline', () => { // console.log('Became offline') this.backgroundservice.offline() diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.html b/src/app/pages/gabinete-digital/gabinete-digital.page.html index 8dac8fd1a..a34d2ac24 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.html +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.html @@ -228,7 +228,7 @@

Despacho do Presidente da República

-

Despachos criados por mim

+

Despachos criados por mim

{{ despachoprstore.count }} Documentos

diff --git a/src/app/pages/login/login.page.html b/src/app/pages/login/login.page.html index 0513e99e6..60acee88b 100644 --- a/src/app/pages/login/login.page.html +++ b/src/app/pages/login/login.page.html @@ -7,9 +7,9 @@
diff --git a/src/app/services/background.service.ts b/src/app/services/background.service.ts index df1843528..505d8b1ca 100644 --- a/src/app/services/background.service.ts +++ b/src/app/services/background.service.ts @@ -15,6 +15,8 @@ export class BackgroundService { funx: Function }[] = [] + status: 'online'| 'offline' = 'online' + constructor( private themeservice: ThemeService, private storageservice: StorageService, @@ -22,14 +24,18 @@ export class BackgroundService { ) { } online() { + if(this.status == 'online') { + return false + } + this.status = 'online' this.paint() - this.callBacks.forEach((e) => { if (e.type == 'Online') { e.funx() } }) + this.status = 'offline' } paint() { @@ -59,6 +65,10 @@ export class BackgroundService { async offline() { + if(this.status == 'offline') { + return false + } + let opts = { headers: {}, } @@ -68,6 +78,7 @@ export class BackgroundService { } catch (error) { if(error.status != 400) { + this.status = 'offline' document.body.style.setProperty(`--color`, "#ffb703"); document.body.style.setProperty(`--color2`, "#ffb703"); document.body.style.setProperty(`--color3`, "#ffb703"); @@ -82,8 +93,6 @@ export class BackgroundService { } } - - } registerBackService(type: 'Offline' | 'Online' | 'Notification', funx: Function, object = '') { @@ -94,5 +103,4 @@ export class BackgroundService { }) } - } diff --git a/src/app/services/network-service.service.ts b/src/app/services/network-service.service.ts index 8e5e32d36..8197b1fb3 100644 --- a/src/app/services/network-service.service.ts +++ b/src/app/services/network-service.service.ts @@ -21,7 +21,11 @@ export class NetworkServiceService { this.initializeNetworkEvents(); let status = this.network.type !== 'none' ? ConnectionStatus.Online : ConnectionStatus.Offline; this.status.next(status); - }); + }); + + this.onNetworkChange().subscribe((status) => { + console.log(status) + }) } diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html index 46461e339..c3e9a94e6 100644 --- a/src/app/shared/header/header.page.html +++ b/src/app/shared/header/header.page.html @@ -5,9 +5,9 @@ @@ -19,14 +19,14 @@
-

Presidente da República

+

GABINETE DIGITAL

-

Presidente da República

+

GABINETE DIGITAL

@@ -45,9 +45,9 @@