add timebomb feature

This commit is contained in:
tiago.kayaya
2021-10-27 08:45:37 +01:00
parent 5c942e6e9b
commit ae9bc339c9
12 changed files with 153 additions and 27 deletions
+39 -1
View File
@@ -1,11 +1,14 @@
import { Injectable } from '@angular/core';
import { ChatService } from '../chat.service';
@Injectable({
providedIn: 'root'
})
export class TimeService {
countDownTime: any;
room: any;
constructor() { }
constructor(private chatService: ChatService) { }
showDateDuration(start:any){
let end;
@@ -13,6 +16,7 @@ export class TimeService {
start = new Date(start);
let customizedDate;
const totalSeconds = Math.floor((end - (start))/1000);;
const totalMinutes = Math.floor(totalSeconds/60);
const totalHours = Math.floor(totalMinutes/60);
@@ -37,6 +41,40 @@ export class TimeService {
}
}
countDownDate(date:any, roomId:string){
/* let timer = setInterval(() =>{ */
console.log('Show TIMER');
let difference = new Date(date).getTime() - new Date().getTime();
let c_day = Math.floor(difference/(1000*60*60*24));
let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60));
let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000);
this.countDownTime = c_day + " : " + c_hours + " : " + c_minutes + " : " + c_seconds ;
if(difference < 0){
//clearInterval(timer);
this.countDownTime = "Expired";
let body = { "roomId":roomId, }
this.chatService.getRoomInfo(roomId).subscribe(room=>{
this.room = room['room'];
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
console.log(res);
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
console.log(res);
});
}
});
}
//})
return this.countDownTime;
}
addZero(i) {
if (i < 10) {
i = "0" + i;