diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index 985272835..f3f2bebab 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -163,12 +163,12 @@ export class PublicationsPage implements OnInit { //this.refreshing() } - deleteAction(id?: string){ + async deleteAction(id?: string){ const loader = this.toastService.loading(); try { - this.publications.DeletePresidentialAction(id).toPromise(); + await this.publications.DeletePresidentialAction(id).toPromise(); this.toastService.successMessage() } catch(e) { this.toastService.badRequest() diff --git a/src/app/shared/popover/actions-options/actions-options.page.ts b/src/app/shared/popover/actions-options/actions-options.page.ts index eeceae5ed..d1cd4a1b4 100644 --- a/src/app/shared/popover/actions-options/actions-options.page.ts +++ b/src/app/shared/popover/actions-options/actions-options.page.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { ModalController, NavParams } from '@ionic/angular'; import { PublicationsService } from 'src/app/services/publications.service'; +import { ToastService } from 'src/app/services/toast.service'; @Component({ selector: 'app-actions-options', @@ -15,6 +16,7 @@ export class ActionsOptionsPage implements OnInit { private modalController: ModalController, private navParams: NavParams, private publicationsService: PublicationsService, + private toastService: ToastService ) { this.id = this.navParams.get('id'); } @@ -30,9 +32,21 @@ export class ActionsOptionsPage implements OnInit { this.modalController.dismiss('edit'); } - deleteAction(){ - this.publicationsService.DeletePresidentialAction(this.id).toPromise(); - this.modalController.dismiss('delete'); + async deleteAction() { + + const loader = this.toastService.loading(); + + try { + await this.publicationsService.DeletePresidentialAction(this.id).toPromise(); + this.modalController.dismiss('delete'); + } catch(e) { + this.toastService.badRequest() + } + finally { + loader.remove() + } + + } }