This commit is contained in:
Peter Maquiran
2022-06-08 16:09:40 +01:00
parent b3186c6eed
commit 16ae54d8d1
8 changed files with 114 additions and 156 deletions
+38 -37
View File
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { ChatService } from '../chat.service';
import { WsChatMethodsService } from '../chat/ws-chat-methods.service';
@Injectable({
providedIn: 'root'
@@ -8,14 +9,13 @@ export class TimeService {
countDownTime: any;
room: any;
constructor(private chatService: ChatService) { }
constructor(private chatService: ChatService,
public wsChatMethodsService: WsChatMethodsService,) { }
showDateDuration(start:any){
showDateDuration(start:any) {
let end;
end = new Date();
start = new Date(start);
let customizedDate;
const totalSeconds = Math.floor((end - (start))/1000);;
const totalMinutes = Math.floor(totalSeconds/60);
@@ -26,51 +26,51 @@ export class TimeService {
const minutes = totalMinutes - ( totalDays * 24 * 60 ) - ( hours * 60 );
const seconds = totalSeconds - ( totalDays * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 );
if(totalDays == 0){
if(start.getDate() == new Date().getDate()){
if(totalDays == 0) {
if(start.getDate() == new Date().getDate()) {
let time = start.getHours() + ":" + this.addZero(start.getUTCMinutes());
return time;
}
else{
else {
return 'Ontem';
}
}
else{
else {
let date = this.addZero(start.getDate()) + "/" + this.addZero(start.getMonth()+1) + "/" + start.getFullYear();
return date;
}
}
countDownDate(date:any, roomId:string){
/* let timer = setInterval(() =>{ */
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);
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 = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(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(difference < 0){
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
});
}
});
}
//})
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=>{
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
});
}
});
}
return this.countDownTime;
}
@@ -84,7 +84,7 @@ export class TimeService {
this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
if(difference < 0){
if(difference < 0) {
clearInterval(timer);
this.countDownTime = "Expired";
let body = { "roomId":roomId, }
@@ -93,12 +93,13 @@ export class TimeService {
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
this.wsChatMethodsService.deleteRoom(roomId)
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
this.wsChatMethodsService.deleteRoom(roomId)
});
}
});