added the edit and delete event offline

This commit is contained in:
Eudes Inácio
2021-10-20 11:06:00 +01:00
parent a77fffe6f8
commit f181bd12d9
7 changed files with 163 additions and 188 deletions
+12 -28
View File
@@ -23,7 +23,7 @@ import { Network } from '@ionic-native/network/ngx';
import { BackgroundService } from 'src/app/services/background.service';
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
import { Storage } from '@ionic/storage';
import { EventsService} from 'src/app/services/events.service';
import { EventsService } from 'src/app/services/events.service';
@Component({
@@ -81,11 +81,10 @@ export class HomePage implements OnInit {
private inativityService: InativityService,
private storageService: StorageService,
private webNotificationPopupService: WebNotificationPopupService,
private network: Network,
private backgroundservice: BackgroundService,
private offlinemanager: OfflineManagerService,
private storage: Storage,
private eventservice: EventsService ) {
private eventservice: EventsService) {
this.webNotificationPopupService.askNotificationPermission()
@@ -118,37 +117,20 @@ export class HomePage implements OnInit {
window.addEventListener('online', () => {
console.log('Became online')
this.backgroundservice.online()
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.webnotification.webconnection();
this.webnotification.register();
} else {
this.mobilefirstConnect();
this.notificationsService.onReceviNotification();
this.offlinemanager.synchnize()
}
});
window.addEventListener('offline', () => {
console.log('Became offline')
this.backgroundservice.offline()
});
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.webnotification.webconnection();
this.webnotification.register();
} else {
window.addEventListener('online', (on) => {
console.log('Became online',on)
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.backgroundservice.online()
});
window.addEventListener('offline', (off) => {
console.log('Became offline',off)
this.backgroundservice.offline()
});
this.mobilefirstConnect();
this.notificationsService.onReceviNotification();
}
this.updateList()
var myWorker = new Worker(new URL('./nice.worker.js', import.meta.url));
@@ -197,6 +179,8 @@ export class HomePage implements OnInit {
}
}
updateList() {
this.notificationsService.registerCallback(