From 2b4b879970ce902dee81bc6046d08b6e5fe29bc8 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Fri, 10 Mar 2023 15:46:37 +0100 Subject: [PATCH] remove duplication from publication --- .../pages/publications/publications.page.ts | 68 ++++++------------- version/git-version.ts | 12 ++-- 2 files changed, 25 insertions(+), 55 deletions(-) diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index 8a9402f82..8ce820f8e 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -89,7 +89,6 @@ export class PublicationsPage implements OnInit { }); this.hideRefreshButton(); - this.getFromDB() } @@ -148,38 +147,22 @@ export class PublicationsPage implements OnInit { this.showLoader = false; const folders: PublicationFolder[] = this.getPublicationFolderMap(res) - // let publications = await ActionModel.create(folders) - // console.log('publications', publications) this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento') this.publicationsTravelFolderList = folders.filter((e)=>e.ActionType != 'Evento') - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - await this.storage.set('actionsEvents', this.publicationsEventFolderList); - await this.storage.set('actionsViagens', this.publicationsTravelFolderList); - } else { - folders.forEach((folder)=> { - this.addActionToDB(folder); - }) - } + await this.storage.set('actionsEvents', this.publicationsEventFolderList); + await this.storage.set('actionsViagens', this.publicationsTravelFolderList); this.showLoader = false; }, (error) => { this.showLoader = false; + this.getFromDB() }); } - // addActionToStorage(events, viagens) { - - // if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - // this.storage.set('actionsEvents', events); - // this.storage.set('actionsViagens', viagens); - // } - // } - - addActionToDB(folder) { if (this.platform.is('desktop') || this.platform.is('mobileweb')) { } else { @@ -202,39 +185,26 @@ export class PublicationsPage implements OnInit { } getFromDB() { - - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - this.storage.get('actionsEvents').then((events = []) => { + this.storage.get('actionsEvents').then((events = []) => { - if(Array.isArray(events)) { - const folders: PublicationFolder[] = this.getPublicationFolderMap(events) + if(Array.isArray(events)) { + const folders: PublicationFolder[] = this.getPublicationFolderMap(events) - this.showLoader = false; - this.publicationsEventFolderList = folders - } - - }); - this.storage.get('actionsViagens').then((viagens = []) => { - - if(Array.isArray(viagens)) { - const folders: PublicationFolder[] = this.getPublicationFolderMap(viagens) - - this.publicationsTravelFolderList = folders - this.showLoader = false; - } - - }); - } else { - this.sqliteservice.getAllActions().then((actions: any[] = []) => { - - const folders: PublicationFolder[] = this.getPublicationFolderMap(actions) - - this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento') - this.publicationsTravelFolderList = folders.filter((e)=>e.ActionType != 'Evento') this.showLoader = false; + this.publicationsEventFolderList = folders + } - }) - } + }); + this.storage.get('actionsViagens').then((viagens = []) => { + + if(Array.isArray(viagens)) { + const folders: PublicationFolder[] = this.getPublicationFolderMap(viagens) + + this.publicationsTravelFolderList = folders + this.showLoader = false; + } + + }); } async editAction(folderId?: string) { diff --git a/version/git-version.ts b/version/git-version.ts index edb588f7c..05772e481 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "5b0606420", - "SHA": "5b060642036e92e97d14f9926b9e49e29257fd43", + "shortSHA": "57b4f0880", + "SHA": "57b4f0880084a1ab1005660d19cb603fa7b279ad", "branch": "no_bug_movemente", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Fri Mar 10 14:30:50 2023 +0100'", - "lastCommitMessage": "update actions", - "lastCommitNumber": "4866", + "lastCommitTime": "'Fri Mar 10 15:10:37 2023 +0100'", + "lastCommitMessage": "improve publication", + "lastCommitNumber": "4867", "change": "", - "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/pages/publications/view-publications/view-publications.page.html\n\tmodified: src/app/pages/publications/view-publications/view-publications.page.ts\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.html\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts", + "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/pages/publications/publications.page.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file