Files
doneit-web/src/app/services/alert.service.ts
T

75 lines
1.8 KiB
TypeScript
Raw Normal View History

import { Injectable } from '@angular/core';
2021-06-09 10:01:45 +01:00
import { AlertController, AnimationController } from '@ionic/angular';
2022-09-30 15:13:36 +01:00
import { ChatSystemService } from './chat/chat-system.service';
2021-09-28 15:23:51 +01:00
import { ToastService } from './toast.service';
@Injectable({
providedIn: 'root'
})
export class AlertService {
2021-06-09 10:01:45 +01:00
constructor(
public alertController: AlertController,
private animationController: AnimationController,
2021-09-28 15:23:51 +01:00
private toastService: ToastService,
2022-09-30 15:13:36 +01:00
public ChatSystemService: ChatSystemService,
2021-06-09 10:01:45 +01:00
) { }
async presentAlert(message:string) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Mensagem do sistema',
message: message,
buttons: ['OK']
});
await alert.present();
}
2021-05-03 12:57:26 +01:00
async presentErrorMessage(message:string) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Mensagem de erro',
message: message,
});
await alert.present();
2021-09-28 15:23:51 +01:00
2021-05-03 12:57:26 +01:00
setTimeout(()=>{
alert.dismiss();
}, 2500);
}
2022-01-28 15:31:52 +01:00
async confirmDeleteMessage(msgId:any, room:any) {
2021-09-28 15:23:51 +01:00
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Apagar a mensagem?',
buttons: [
{
text: 'Cancelar',
role: 'cancel',
cssClass: 'secondary',
handler: () => {
2022-04-28 09:32:27 +01:00
//
2021-09-28 15:23:51 +01:00
}
}, {
text: 'Apagar',
handler: () => {
2022-01-28 15:31:52 +01:00
//const loader = this.toastService.loading();
2022-02-16 13:52:32 +01:00
2022-09-30 15:13:36 +01:00
this.ChatSystemService.deleteMessage(msgId).then(() => {
2022-02-09 17:06:12 +01:00
room.deleteMessage(msgId)
})
2022-09-30 15:13:36 +01:00
//this.ChatSystemService.subscribeToRoomUpdate(room._id, room);
2022-01-28 15:31:52 +01:00
//loader.remove();
2021-09-28 15:23:51 +01:00
}
}
]
});
await alert.present();
}
}