Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into developer

This commit is contained in:
Peter Maquiran
2021-11-16 14:51:36 +01:00
8 changed files with 275 additions and 73 deletions
+52 -3
View File
@@ -22,7 +22,9 @@ 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 { ProcessesService } from 'src/app/services/processes.service';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
import { SqliteService } from 'src/app/services/sqlite.service';
@Component({
selector: 'app-home',
@@ -83,7 +85,9 @@ export class HomePage implements OnInit {
private offlinemanager: OfflineManagerService,
private storage: Storage,
private eventservice: EventsService,
private screenOrientation: ScreenOrientation,) {
private processservice: ProcessesService,
private screenOrientation: ScreenOrientation,
private sqliteservice: SqliteService) {
/* this.webNotificationPopupService.askNotificationPermission() */
@@ -121,8 +125,7 @@ export class HomePage implements OnInit {
this.backgroundservice.online()
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
/* this.notificationsService.onReceviNotification(); */
this.offlinemanager.synchnize()
this.synchWhenOnline()
}
});
window.addEventListener('offline', () => {
@@ -160,4 +163,50 @@ export class HomePage implements OnInit {
}
async synchWhenOnline() {
try {
await this.storage.get('eventEdit').then((req) => {
JSON.parse(req).forEach(element => {
this.eventservice.editEvent(element, 2, 3).subscribe((res) => {
this.storage.remove('eventEdit')
this.sqliteservice.deleteEventTable();
console.log('eventEdit synchnize', res)
})
});
})
} catch (error) {
console.log('error synch eventedit')
}
try {
await this.storage.get('eventDelete').then((req) => {
JSON.parse(req).forEach(element => {
console.log('DELETE data SYNC', element)
this.eventservice.deleteEvent(element.eventid, element.eventDeleteType, element.calendarName).subscribe((res) => {
this.storage.remove('eventDelete')
this.sqliteservice.deleteEventTable();
console.log('eventDelete synchnize', res)
})
});
})
} catch (error) {
console.log('error delete event synch')
}
try {
await this.storage.get('event-listRever').then((req) => {
JSON.parse(req).forEach(element => {
console.log('REVER data SYNC', element)
this.processservice.PostTaskAction(element).subscribe((res) => {
this.storage.remove('event-listRever')
this.sqliteservice.deleteEventTable();
console.log('event-listRever synchnize', res)
})
});
})
} catch (error) {
console.log('error event-list rever synch')
}
}
}