Delete message in chat completed

This commit is contained in:
tiago.kayaya
2021-09-28 15:23:51 +01:00
parent 4f61719f59
commit 988711a104
11 changed files with 94 additions and 29 deletions
+32 -1
View File
@@ -1,5 +1,7 @@
import { Injectable } from '@angular/core';
import { AlertController, AnimationController } from '@ionic/angular';
import { ChatService } from './chat.service';
import { ToastService } from './toast.service';
@Injectable({
providedIn: 'root'
@@ -9,6 +11,8 @@ export class AlertService {
constructor(
public alertController: AlertController,
private animationController: AnimationController,
private chatService: ChatService,
private toastService: ToastService,
) { }
async presentAlert(message:string) {
@@ -30,10 +34,37 @@ export class AlertService {
});
await alert.present();
setTimeout(()=>{
alert.dismiss();
}, 2500);
}
async confirmDeleteMessage(body:any) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Apagar a mensagem?',
buttons: [
{
text: 'Cancelar',
role: 'cancel',
cssClass: 'secondary',
handler: () => {
//console.log('Confirm Cancel');
}
}, {
text: 'Apagar',
handler: () => {
const loader = this.toastService.loading();
this.chatService.deleteMessage(body).subscribe(res=>{
loader.remove();
});
}
}
]
});
await alert.present();
}
}
+10
View File
@@ -52,6 +52,7 @@ export class ChatService {
getAllChannels(){
return this.http.get(environment.apiChatUrl+'channels.list', this.options);
}
getAllUserChannels(){
return this.http.get(environment.apiChatUrl+'channels.list.joined', this.options);
}
@@ -59,6 +60,7 @@ export class ChatService {
getAllRooms(){
return this.http.get(environment.apiChatUrl+'rooms.get', this.options);
}
getRoomInfo(roomId:any){
let params = new HttpParams();
params = params.set("roomId", roomId);
@@ -110,6 +112,14 @@ export class ChatService {
}
return this.http.post(environment.apiChatUrl+'chat.sendMessage', body, opts);
}
deleteMessage(body:any){
let opts = {
headers: this.headers,
}
return this.http.post(environment.apiChatUrl+'chat.delete', body, opts);
}
leaveRoom(body:any){
let opts = {
headers: this.headers,