mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
improve
This commit is contained in:
@@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
|
||||
import { WsChatService } from 'src/app/services/chat/ws-chat.service';
|
||||
import { MessageService } from 'src/app/services/chat/message.service';
|
||||
import { showDateDuration } from 'src/plugin/showDateDuration';
|
||||
import { ToastsService } from '../toast.service';
|
||||
import { chatHistory } from 'src/app/models/chatMethod';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { Platform } from '@ionic/angular';
|
||||
@@ -16,13 +15,14 @@ import { environment } from 'src/environments/environment';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { NfService } from 'src/app/services/chat/nf.service';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { ChatStorageService } from './chat-storage.service'
|
||||
import { ChatMethodsService } from './chat-methods.service'
|
||||
import { DeleteMessageModel, MessageModel } from '../../models/beast-orm'
|
||||
import { AESEncrypt } from '../aesencrypt.service'
|
||||
import { ChatStorageService } from './chat-storage.service';
|
||||
import { ChatMethodsService } from './chat-methods.service';
|
||||
import { DeleteMessageModel, MessageModel } from '../../models/beast-orm';
|
||||
import { AESEncrypt } from '../aesencrypt.service';
|
||||
import { IncomingChatMessage, ChatMessageInterface, falseTypingMethod } from 'src/app/models/message.model';
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { ConnectionStatus, NetworkServiceService} from 'src/app/services/network-service.service';
|
||||
import { WsChatMethodsService } from './ws-chat-methods.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -52,6 +52,7 @@ export class RoomService {
|
||||
members = []
|
||||
u
|
||||
sessionStore = SessionStore
|
||||
countDownTime = ''
|
||||
|
||||
scrollDown = () => { }
|
||||
|
||||
@@ -80,7 +81,8 @@ export class RoomService {
|
||||
private ChatMethodsService: ChatMethodsService,
|
||||
private AESEncrypt: AESEncrypt,
|
||||
private AttachmentsService: AttachmentsService,
|
||||
private NetworkServiceService: NetworkServiceService
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
private wsChatMethodsService: WsChatMethodsService
|
||||
) {
|
||||
this.NativeNotificationService.askForPermission()
|
||||
|
||||
@@ -157,6 +159,58 @@ export class RoomService {
|
||||
|
||||
this.calDateDuration()
|
||||
this.restoreMessageFromDB()
|
||||
|
||||
if(this.customFields?.countDownDate) {
|
||||
this.countDownDate(this.customFields.countDownDate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
countDownDate(date) {
|
||||
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) ;
|
||||
|
||||
if(difference < 0) {
|
||||
|
||||
this.deleteRoom()
|
||||
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.countDownDate(date)
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
addZero(i) {
|
||||
if (i < 10) {
|
||||
i = "0" + i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
deleteRoom() {
|
||||
this.countDownTime = "Expired";
|
||||
let body = { "roomId": this.id }
|
||||
|
||||
this.chatService.getRoomInfo(this.id).subscribe(room=>{
|
||||
|
||||
|
||||
if(this.t === 'p') {
|
||||
this.chatService.deleteGroup(body).subscribe(res=>{
|
||||
this.wsChatMethodsService.deleteRoom(this.id)
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.chatService.deleteChannel(body).subscribe(res=>{
|
||||
this.wsChatMethodsService.deleteRoom(this.id)
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user