Refactoring made on offline

This commit is contained in:
Eudes Inácio
2021-10-18 17:42:25 +01:00
parent a9eee0f9a0
commit a21a196248
20 changed files with 1377 additions and 1322 deletions
+9 -54
View File
@@ -10,7 +10,6 @@ import { AlertController, Platform } from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router';
import { ToDayEventStorage } from '../store/to-day-event-storage.service';
import { TotalDocumentStore } from '../store/total-document.service';
import { synchro } from '../services/socket/synchro.service';
import { DespachoService } from '../Rules/despacho.service';
import { ExpedienteGdStore } from '../store/expedientegd-store.service';
import { InativityService } from '../services/inativity.service';
@@ -66,8 +65,6 @@ export class HomePage implements OnInit {
postEvent: any;
folderId: string;
synchro = synchro
status: string = "";
audioName: string = "";
constructor(
@@ -118,15 +115,16 @@ export class HomePage implements OnInit {
ngOnInit() {
window.addEventListener('online', () => {
console.log('Became online')
this.backgroundservice.online()
});
window.addEventListener('offline', () => {
console.log('Became offline')
this.backgroundservice.offline()
});
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
window.addEventListener('online', () => {
console.log('Became online')
this.backgroundservice.online()
});
window.addEventListener('offline', () => {
console.log('Became offline')
this.backgroundservice.offline()
});
this.webnotification.webconnection();
this.webnotification.register();
} else {
@@ -147,18 +145,6 @@ export class HomePage implements OnInit {
console.log('Became offline',off)
this.backgroundservice.offline()
});
if(synchro.connected === true) {
//this.offlinemanager.checkForEvents().subscribe();
this.storage.get('storedreq').then((req) =>{
console.log('STORED REQUEST', req)
req.forEach(element => {
this.eventservice.editEvent(element,2,3).subscribe((res) =>{
console.log('REQUEST RESULT', res)
})
});
})
}
this.mobilefirstConnect();
this.notificationsService.onReceviNotification();
}
@@ -220,37 +206,6 @@ export class HomePage implements OnInit {
}
)
synchro.registerCallback('Online', () => {
console.log('Onlineee')
})
synchro.registerCallback('Offline',()=>{
})
synchro.conected
synchro.registerCallback('Notification', (DataArray) => {
this.webNotificationPopupService.sendNotification(DataArray)
this.storageService.get('Notifications').then((data:any)=>{
data.push(DataArray)
this.storageService.store("Notifications", data)
}).catch(() => {
const a = []
a.push(DataArray)
this.storageService.store("Notifications", a)
})
}, 'any')
document.addEventListener('pause', function () {
// console.log('App going to background');
});