This commit is contained in:
Peter Maquiran
2022-09-23 11:23:24 +01:00
113 changed files with 691545 additions and 784 deletions
+34 -56
View File
@@ -27,11 +27,10 @@ import { DocumentViewer, DocumentViewerOptions } from '@ionic-native/document-vi
import { VoiceRecorder, RecordingData, GenericResponse } from 'capacitor-voice-recorder';
import { Filesystem, Directory } from '@capacitor/filesystem';
import { DomSanitizer } from '@angular/platform-browser';
import { AlertController, Platform } from '@ionic/angular';
import { Platform } from '@ionic/angular';
import { File } from '@awesome-cordova-plugins/file/ngx';
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorResponse } from '@angular/common/http';
import { Howl } from 'howler';
import { runInThisContext } from 'vm';
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
@@ -49,8 +48,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
@ViewChild('message-item') messageContainer: ElementRef;
loggedUser: any;
messages: any;
dm: any;
userPresence = '';
@@ -100,6 +97,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
audioTimer: any;
@ViewChild('range', { static: false }) range: IonRange;
userName = "";
room: any = new Array();
roomName: any;
isAdmin = false;
roomCountDownDate: string;
constructor(
public popoverController: PopoverController,
@@ -123,12 +124,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
private platform: Platform,
private fileOpener: FileOpener,
) {
this.loggedUser = authService.ValidatedUserChat['data'];
this.checkAudioPermission()
}
ngOnChanges(changes: SimpleChanges): void {
this.wsChatMethodsService.getAllRooms();
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
@@ -165,11 +166,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
async ngOnInit() {
this.wsChatMethodsService.getAllRooms();
alert(this.wsChatMethodsService.getDmRoom(this.roomId).name)
this.chatService.refreshtoken();
this.scrollToBottom();
this.getChatMembers();
this.deleteRecording();
@@ -375,7 +376,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
return this.timeService.showDateDuration(start);
}
async goToEvent(eventId: any) {
async goToEvent(event: any) {
let classs;
if (window.innerWidth < 701) {
classs = 'modal modal-desktop'
@@ -385,7 +386,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const modal = await this.modalController.create({
component: ViewEventPage,
componentProps: {
eventId: eventId,
eventId: event.id,
CalendarId: event.calendarId
},
cssClass: classs,
});
@@ -441,22 +443,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
deleteMessage(msgId: string, msg: MessageService) {
this.wsChatMethodsService.getDmRoom(this.roomId).sendDeleteRequest(msgId)
if (msg.file.type == "application/webtrix") {
// this.openViewDocumentModal(msg.file);
}
else {
var str = msg.attachments[0].image_url;
str = str.substring(1, ((str.length) - 1));
const encodedData = btoa(str);
let file = this.base64toBlob(encodedData, 'application/pdf')
let fileURL = URL.createObjectURL(file)
window.open(fileURL);
}
}
base64toBlob(base64Data, contentType) {
@@ -667,7 +653,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const roomId = this.roomId
const image = await this.CameraService.takePicture();
await this.fileService.saveImage(image)
await this.fileService.saveImage(image);
const lastphoto: any = await this.fileService.loadFiles();
const { capturedImage, capturedImageTitle } = await this.fileService.loadFileData(lastphoto);
const base64 = await fetch(capturedImage);
@@ -1028,33 +1014,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
this.downloadFileMsg(msg)
/* } else if (msg.file.type === "application/pdf") {
const win = window.open("", "_blank");
let html = '';
html += '<html>';
html += '<body style="margin:0!important">';
html += '<iframe width="100%" height="100%" src="' + str + '" type="application/pdf" />';
html += '</body>';
html += '</html>';
setTimeout(() => {
win.document.write(html);
}, 0); */
//this.viewDocument(msg, msg.attachments.image_url)
} else {
var str = msg.attachments[0].image_url;
str = str.substring(1, ((str.length) - 1));
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log(msg)
if (msg.file.type == "application/img") {
const modal = await this.modalController.create({
@@ -1079,19 +1044,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
}
}
testEditMessage(msg: MessageService) {
// msg.receptorReceive()
// alert('cool!')
}
start(track) {
if (this.audioPlay) {
this.audioPlay.stop();
@@ -1138,6 +1095,27 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}, 1000)
}
async getRoomInfo() {
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
// console.log('ROOM',room)
this.room = room['room'];
if (this.room.name) {
this.roomName = this.room.name.split('-').join(' ');
}
if(SessionStore.user.ChatData.data.userId == this.room.u._id){
this.isAdmin = true
} else {
this.isAdmin = false
}
if (this.room.customFields.countDownDate) {
this.roomCountDownDate = this.room.customFields.countDownDate;
}
}
}