2022-04-26 16:14:55 +01:00
|
|
|
import { Component, ElementRef, OnInit, ViewChild, AfterViewInit, OnDestroy, ChangeDetectorRef, } from '@angular/core';
|
2022-04-26 16:53:10 +01:00
|
|
|
import { IonSlides, ModalController, NavParams, PopoverController, Platform } from '@ionic/angular';
|
2021-04-13 14:14:55 +01:00
|
|
|
import { AlertService } from 'src/app/services/alert.service';
|
2021-01-19 16:10:40 +01:00
|
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
|
|
|
import { ChatService } from 'src/app/services/chat.service';
|
2020-12-29 12:40:19 +01:00
|
|
|
import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popover/chat-options-popover.page';
|
2020-12-28 10:11:00 +01:00
|
|
|
import { ChatPopoverPage } from 'src/app/shared/popover/chat-popover/chat-popover.page';
|
2021-01-21 16:27:04 +01:00
|
|
|
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
2022-03-03 08:21:22 +01:00
|
|
|
import { Router } from '@angular/router'
|
2021-08-17 14:17:19 +01:00
|
|
|
import { EditGroupPage } from '../edit-group/edit-group.page';
|
2021-09-06 16:53:58 +01:00
|
|
|
import { TimeService } from 'src/app/services/functions/time.service';
|
2021-09-14 10:30:13 +01:00
|
|
|
import { FileService } from 'src/app/services/functions/file.service';
|
2021-09-14 10:48:28 +01:00
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
2021-09-21 14:05:59 +01:00
|
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
|
import { NewEventPage } from '../../agenda/new-event/new-event.page';
|
|
|
|
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
2021-10-05 16:29:33 +01:00
|
|
|
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
2021-10-23 09:53:21 +01:00
|
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
2021-12-22 10:31:10 +01:00
|
|
|
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
2022-01-13 17:28:35 +01:00
|
|
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
2022-01-14 11:53:14 +01:00
|
|
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
2022-02-03 21:01:53 +01:00
|
|
|
import { FileType } from 'src/app/models/fileType';
|
|
|
|
|
import { Storage } from '@ionic/storage';
|
2022-02-04 07:42:43 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
import { CameraService } from 'src/app/services/camera.service';
|
|
|
|
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
2022-04-26 16:53:10 +01:00
|
|
|
import { VoiceRecorder, RecordingData, GenericResponse } from 'capacitor-voice-recorder';
|
|
|
|
|
import { Filesystem, Directory } from '@capacitor/filesystem';
|
2022-03-18 11:45:38 +01:00
|
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
2022-03-22 16:11:30 +01:00
|
|
|
import { MessageService } from 'src/app/services/chat/message.service';
|
2022-04-05 13:22:17 +01:00
|
|
|
import { File } from '@awesome-cordova-plugins/file/ngx';
|
|
|
|
|
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
2022-04-19 14:48:22 +01:00
|
|
|
import { SessionStore } from 'src/app/store/session.service';
|
2022-07-06 17:02:42 +01:00
|
|
|
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
2020-12-28 10:11:00 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-group-messages',
|
|
|
|
|
templateUrl: './group-messages.page.html',
|
|
|
|
|
styleUrls: ['./group-messages.page.scss'],
|
|
|
|
|
})
|
2021-08-23 16:31:06 +01:00
|
|
|
export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
2021-11-17 15:34:15 +01:00
|
|
|
|
2021-01-27 16:01:49 +01:00
|
|
|
showLoader: boolean;
|
2022-03-03 08:21:22 +01:00
|
|
|
isGroupCreated: boolean;
|
2021-01-19 16:10:40 +01:00
|
|
|
loggedUser: any;
|
2021-01-21 16:27:04 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
room: any;
|
|
|
|
|
roomName: any;
|
|
|
|
|
members: any;
|
2021-03-12 11:56:54 +01:00
|
|
|
contacts: string[] = [" Ana M.", "Andre F.", "Bruno G.", "Catarina T", "Tiago"];
|
2022-03-03 08:21:22 +01:00
|
|
|
allUsers: any[] = [];
|
2020-12-28 10:11:00 +01:00
|
|
|
|
2021-03-12 17:35:54 +01:00
|
|
|
roomId: string;
|
2022-03-03 08:21:22 +01:00
|
|
|
loggedUserChat: any;
|
2021-08-18 09:23:53 +01:00
|
|
|
eventSelectedDate: Date = new Date();
|
2021-03-12 17:35:54 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
scrollingOnce: boolean = true;
|
2021-08-23 16:31:06 +01:00
|
|
|
private scrollChangeCallback: () => void;
|
|
|
|
|
currentPosition: any;
|
|
|
|
|
startPosition: number;
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
capturedImage: any;
|
|
|
|
|
capturedImageTitle: any;
|
2021-09-21 14:05:59 +01:00
|
|
|
attendees: EventPerson[] = [];
|
2021-09-24 15:39:25 +01:00
|
|
|
scrollToBottomBtn = false;
|
2021-09-13 12:37:58 +01:00
|
|
|
|
2021-09-30 12:23:22 +01:00
|
|
|
longPressActive = false;
|
|
|
|
|
showMessageOptions = false;
|
2022-03-03 08:21:22 +01:00
|
|
|
selectedMsgId: string;
|
|
|
|
|
roomCountDownDate: any;
|
2022-01-13 17:28:35 +01:00
|
|
|
downloadFile: any;
|
2022-06-29 16:45:39 +01:00
|
|
|
groupNameFormart = "";
|
2021-09-30 12:23:22 +01:00
|
|
|
|
2021-07-26 14:09:26 +01:00
|
|
|
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
|
|
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
recording = false;
|
|
|
|
|
allowTyping = true;
|
|
|
|
|
storedFileNames = [];
|
|
|
|
|
lastAudioRecorded = '';
|
2022-04-05 13:22:17 +01:00
|
|
|
audioRecorded: any = "";
|
|
|
|
|
audioDownloaded: any = "";
|
2022-03-14 17:11:00 +01:00
|
|
|
durationDisplay = '';
|
|
|
|
|
duration = 0;
|
2022-03-18 16:29:10 +01:00
|
|
|
showAvatar = true;
|
2022-04-02 09:40:09 +01:00
|
|
|
audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null
|
2022-04-19 16:03:59 +01:00
|
|
|
sessionStore = SessionStore
|
2022-07-01 14:28:57 +01:00
|
|
|
isAdmin = false;
|
2020-12-28 10:11:00 +01:00
|
|
|
constructor(
|
2020-12-29 12:40:19 +01:00
|
|
|
private modalController: ModalController,
|
2020-12-28 10:11:00 +01:00
|
|
|
public popoverController: PopoverController,
|
2021-01-19 16:10:40 +01:00
|
|
|
private chatService: ChatService,
|
2021-03-12 11:56:54 +01:00
|
|
|
private navParams: NavParams,
|
2021-01-19 16:10:40 +01:00
|
|
|
private authService: AuthService,
|
2021-04-13 14:14:55 +01:00
|
|
|
private alertService: AlertService,
|
2021-09-06 16:53:58 +01:00
|
|
|
private route: Router,
|
|
|
|
|
private timeService: TimeService,
|
2021-09-14 10:30:13 +01:00
|
|
|
private fileService: FileService,
|
2021-09-14 10:48:28 +01:00
|
|
|
private toastService: ToastService,
|
2021-11-17 15:34:15 +01:00
|
|
|
public ThemeService: ThemeService,
|
2022-01-13 17:28:35 +01:00
|
|
|
private changeDetectorRef: ChangeDetectorRef,
|
|
|
|
|
private sqlservice: SqliteService,
|
|
|
|
|
private platform: Platform,
|
2022-02-03 21:01:53 +01:00
|
|
|
public wsChatMethodsService: WsChatMethodsService,
|
|
|
|
|
private storage: Storage,
|
|
|
|
|
private CameraService: CameraService,
|
2022-03-18 11:45:38 +01:00
|
|
|
private sanitiser: DomSanitizer,
|
2022-04-05 13:22:17 +01:00
|
|
|
private file: File,
|
|
|
|
|
private fileOpener: FileOpener,
|
2021-01-21 16:27:04 +01:00
|
|
|
) {
|
2021-07-23 14:43:51 +01:00
|
|
|
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
2021-01-21 16:27:04 +01:00
|
|
|
this.isGroupCreated = true;
|
2021-03-12 17:35:54 +01:00
|
|
|
this.roomId = this.navParams.get('roomId');
|
2021-09-03 17:02:42 +01:00
|
|
|
window.onresize = (event) => {
|
2022-03-03 08:21:22 +01:00
|
|
|
if (window.innerWidth > 701) {
|
2021-09-03 17:02:42 +01:00
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-01-14 14:58:47 +01:00
|
|
|
|
2022-02-09 17:06:12 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
|
2022-01-14 14:58:47 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked;
|
2022-01-29 19:21:46 +01:00
|
|
|
this.wsChatMethodsService.openRoom(this.roomId)
|
2022-06-29 16:45:39 +01:00
|
|
|
this.groupNameFormart = this.wsChatMethodsService.getGroupRoom(this.roomId).name.split('-').join(' ')
|
2022-02-09 15:09:47 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
setTimeout(() => {
|
2022-01-14 14:58:47 +01:00
|
|
|
this.scrollToBottomClicked()
|
|
|
|
|
}, 50)
|
|
|
|
|
|
2022-03-18 16:29:10 +01:00
|
|
|
|
|
|
|
|
this.showAvatar = false
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.scrollToBottomClicked()
|
|
|
|
|
this.showAvatar = true
|
|
|
|
|
}, 150)
|
|
|
|
|
|
2021-01-19 16:10:40 +01:00
|
|
|
}
|
2020-12-28 10:11:00 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2022-06-10 09:42:41 +01:00
|
|
|
this.chatService.refreshtoken();
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
this.loggedUser = this.loggedUserChat;
|
2021-03-12 17:35:54 +01:00
|
|
|
this.getRoomInfo();
|
2021-07-26 14:34:52 +01:00
|
|
|
this.scrollToBottom();
|
2021-07-26 19:31:19 +01:00
|
|
|
this.serverLongPull();
|
2021-08-23 16:31:06 +01:00
|
|
|
this.setStatus('online');
|
2021-09-09 11:47:49 +01:00
|
|
|
this.getChatMembers();
|
2022-01-13 17:28:35 +01:00
|
|
|
|
|
|
|
|
this.getRoomMessageDB(this.roomId);
|
2022-02-03 16:36:05 +01:00
|
|
|
this.wsChatMethodsService.getUserOfRoom(this.roomId).then((value) => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-02-03 16:36:05 +01:00
|
|
|
})
|
2022-05-27 16:53:09 +01:00
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
setStatus(status: string) {
|
2021-08-23 16:31:06 +01:00
|
|
|
let body = {
|
|
|
|
|
message: '',
|
|
|
|
|
status: status,
|
|
|
|
|
}
|
2022-04-07 14:40:37 +01:00
|
|
|
// this.chatService.setUserStatus(body).subscribe(res => {
|
2022-04-28 09:32:27 +01:00
|
|
|
//
|
2022-04-07 14:40:37 +01:00
|
|
|
// })
|
2021-08-23 16:31:06 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
deleteMessage(msgId: string) {
|
2022-03-14 20:44:41 +01:00
|
|
|
const room = this.wsChatMethodsService.getGroupRoom(this.roomId)
|
|
|
|
|
this.alertService.confirmDeleteMessage(msgId, room);
|
2021-09-30 12:23:22 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
ngAfterViewInit() {
|
|
|
|
|
this.scrollChangeCallback = () => this.onContentScrolled(event);
|
|
|
|
|
window.addEventListener('scroll', this.scrollChangeCallback, true);
|
2022-08-09 17:01:44 +01:00
|
|
|
|
|
|
|
|
if(this.room?.customFields?.countDownDate) {
|
|
|
|
|
this.roomCountDownDate = this.timeService.countDownDate(this.room.customFields.countDownDate, this.room._id);
|
|
|
|
|
}
|
2021-08-23 16:31:06 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
handlePress(id?: string) {
|
2021-09-30 12:23:22 +01:00
|
|
|
this.selectedMsgId = id;
|
|
|
|
|
this.showMessageOptions = true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
handleClick() {
|
2021-09-30 12:23:22 +01:00
|
|
|
this.showMessageOptions = false;
|
|
|
|
|
this.selectedMsgId = "";
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-24 15:39:25 +01:00
|
|
|
onContentScrolled(e) {
|
2021-08-23 16:31:06 +01:00
|
|
|
this.startPosition = e.srcElement.scrollTop;
|
|
|
|
|
let scroll = e.srcElement.scrollTop;
|
2021-09-24 15:39:25 +01:00
|
|
|
let windowHeight = e.srcElement.scrollHeight;
|
2021-09-24 16:10:24 +01:00
|
|
|
let containerHeight = windowHeight - e.srcElement.clientHeight;
|
2021-09-24 15:39:25 +01:00
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
if (scroll > this.currentPosition) {
|
|
|
|
|
//alert('BOTTOM');
|
|
|
|
|
} else {
|
|
|
|
|
//alert('UP');
|
|
|
|
|
this.scrollingOnce = false;
|
|
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
if ((containerHeight - 100) > scroll) {
|
2021-09-24 15:39:25 +01:00
|
|
|
this.scrollToBottomBtn = true;
|
|
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
else {
|
2021-09-24 15:39:25 +01:00
|
|
|
this.scrollToBottomBtn = false;
|
|
|
|
|
}
|
2021-08-23 16:31:06 +01:00
|
|
|
this.currentPosition = scroll;
|
2021-03-12 17:35:54 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
calculateDuration() {
|
|
|
|
|
if (!this.recording) {
|
|
|
|
|
this.duration = 0;
|
|
|
|
|
this.durationDisplay = '';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.duration += 1;
|
|
|
|
|
const minutes = Math.floor(this.duration / 60);
|
|
|
|
|
const seconds = (this.duration % 60).toString().padStart(2, '0');
|
|
|
|
|
this.durationDisplay = `${minutes}:${seconds}`;
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.calculateDuration();
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
async getFile(fileName?: any) {
|
2022-03-14 17:11:00 +01:00
|
|
|
const audioFile = await Filesystem.readFile({
|
|
|
|
|
path: fileName,
|
|
|
|
|
directory: Directory.Data
|
|
|
|
|
})
|
2022-04-28 09:32:27 +01:00
|
|
|
//
|
2022-03-14 17:11:00 +01:00
|
|
|
const base64sound = audioFile.data;
|
|
|
|
|
|
|
|
|
|
//Converting base64 to blob
|
|
|
|
|
const base64 = await fetch(base64sound);
|
2022-04-28 09:32:27 +01:00
|
|
|
//
|
2022-03-14 17:11:00 +01:00
|
|
|
|
|
|
|
|
const base64Response = await fetch(`data:audio/ogg;base64,${base64sound}`);
|
2022-04-28 09:32:27 +01:00
|
|
|
//
|
2022-03-14 17:11:00 +01:00
|
|
|
|
|
|
|
|
this.audioRecorded = base64Response.url;
|
|
|
|
|
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async loadFiles() {
|
2022-03-18 11:45:38 +01:00
|
|
|
|
|
|
|
|
this.storage.get('fileName').then((fileName) => {
|
|
|
|
|
this.lastAudioRecorded = fileName;
|
2022-03-14 17:11:00 +01:00
|
|
|
})
|
2022-03-18 11:45:38 +01:00
|
|
|
|
2022-03-22 14:23:38 +01:00
|
|
|
try {
|
|
|
|
|
this.storage.get('recordData').then((recordData) => {
|
2022-04-18 15:27:16 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
|
2022-03-24 17:40:14 +01:00
|
|
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64);
|
2022-03-22 14:23:38 +01:00
|
|
|
}
|
2022-04-18 15:24:01 +01:00
|
|
|
else if(recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
|
2022-03-24 17:40:14 +01:00
|
|
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`);
|
2022-03-22 14:23:38 +01:00
|
|
|
}
|
|
|
|
|
});
|
2022-04-05 13:22:17 +01:00
|
|
|
} catch (error) { }
|
2022-03-22 14:23:38 +01:00
|
|
|
|
|
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stopRecording() {
|
2022-03-18 11:45:38 +01:00
|
|
|
this.deleteRecording();
|
2022-03-14 17:11:00 +01:00
|
|
|
this.allowTyping = false;
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
if (!this.recording) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.recording = false;
|
|
|
|
|
VoiceRecorder.stopRecording().then(async (result: RecordingData) => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-03-27 15:18:54 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
this.recording = false;
|
|
|
|
|
if (result.value && result.value.recordDataBase64) {
|
|
|
|
|
const recordData = result.value.recordDataBase64;
|
2022-04-18 15:27:16 +01:00
|
|
|
//
|
2022-03-18 16:43:15 +01:00
|
|
|
const fileName = new Date().getTime() + ".mp3";
|
2022-03-18 11:45:38 +01:00
|
|
|
//Save file
|
2022-04-05 13:22:17 +01:00
|
|
|
await this.storage.set('fileName', fileName)
|
|
|
|
|
this.storage.set('recordData', result).then(() => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-03-24 17:40:14 +01:00
|
|
|
|
|
|
|
|
setTimeout(async () => {
|
|
|
|
|
this.loadFiles();
|
|
|
|
|
}, 1000);
|
2022-03-14 17:11:00 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-03-27 15:18:54 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-07 15:22:25 +01:00
|
|
|
async startRecording() {
|
2022-05-27 16:53:09 +01:00
|
|
|
VoiceRecorder.requestAudioRecordingPermission();
|
2022-04-07 15:22:25 +01:00
|
|
|
if(await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) =>{return result.value})){
|
|
|
|
|
if(await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => {return result.value})){
|
|
|
|
|
//if(await this.hasAudioRecordingPermission()){
|
|
|
|
|
if (this.recording) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.recording = true;
|
|
|
|
|
VoiceRecorder.startRecording();
|
|
|
|
|
this.calculateDuration();
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.toastService._badRequest('Para gravar uma mensagem de voz, permita o acesso do Gabinete Digital ao seu microfone.');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
this.toastService._badRequest('Este dispositivo não tem capacidade para gravação de áudio!');
|
2022-03-24 17:40:14 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
async deleteRecording() {
|
2022-03-18 11:45:38 +01:00
|
|
|
this.storage.remove('fileName');
|
|
|
|
|
this.storage.remove('recordData');
|
|
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
this.allowTyping = true;
|
|
|
|
|
this.lastAudioRecorded = '';
|
|
|
|
|
this.loadFiles();
|
|
|
|
|
}
|
2022-01-28 16:15:20 +01:00
|
|
|
|
2021-12-22 10:31:10 +01:00
|
|
|
async goToEvent(eventId: any) {
|
|
|
|
|
let classs;
|
|
|
|
|
if (window.innerWidth < 701) {
|
|
|
|
|
classs = 'modal modal-desktop'
|
|
|
|
|
} else {
|
|
|
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewEventPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
eventId: eventId,
|
|
|
|
|
},
|
|
|
|
|
cssClass: classs,
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res) => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-12-22 10:31:10 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
|
window.removeEventListener('scroll', this.scrollChangeCallback, true);
|
2021-07-26 14:09:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scrollToBottom(): void {
|
|
|
|
|
try {
|
2022-03-03 08:21:22 +01:00
|
|
|
if (this.scrollingOnce) {
|
2021-08-23 16:31:06 +01:00
|
|
|
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
|
|
|
|
//this.scrollingOnce = false;
|
|
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
} catch (err) { }
|
2021-04-13 14:14:55 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-14 14:50:47 +01:00
|
|
|
scrollToBottomClicked = () => {
|
2021-09-24 15:39:25 +01:00
|
|
|
try {
|
|
|
|
|
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
2022-03-03 08:21:22 +01:00
|
|
|
} catch (err) { }
|
2021-09-24 15:39:25 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-01 14:28:57 +01:00
|
|
|
async getRoomInfo() {
|
2021-03-12 17:35:54 +01:00
|
|
|
this.showLoader = true;
|
2022-04-07 14:40:37 +01:00
|
|
|
// this.chatService.getRoomInfo(this.roomId).subscribe(room => {
|
|
|
|
|
// this.room = room['room'];
|
|
|
|
|
// this.roomName = this.room.name.split('-').join(' ');
|
|
|
|
|
// if (this.room.customFields.countDownDate) {
|
|
|
|
|
// this.roomCountDownDate = this.timeService.countDownDateTimer(this.room.customFields.countDownDate, this.room._id);
|
|
|
|
|
// }
|
|
|
|
|
// this.getGroupContacts(this.room);
|
|
|
|
|
// this.showLoader = false;
|
|
|
|
|
// });
|
2022-07-01 14:28:57 +01:00
|
|
|
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;
|
|
|
|
|
}
|
2021-03-12 11:56:54 +01:00
|
|
|
}
|
2021-03-12 17:35:54 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
async getChatMembers() {
|
|
|
|
|
this.chatService.getAllUsers().subscribe(res => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-09-09 11:47:49 +01:00
|
|
|
|
2022-04-26 14:34:52 +01:00
|
|
|
this.allUsers = res['users'].filter(data => data.username != SessionStore.user.UserName);
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-09-09 11:47:49 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-12 17:35:54 +01:00
|
|
|
/* load(){
|
2021-03-12 11:56:54 +01:00
|
|
|
this.getGroupContacts();
|
|
|
|
|
this.loadGroupMessages();
|
2021-03-12 17:35:54 +01:00
|
|
|
} */
|
2021-01-26 15:18:03 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
close() {
|
2021-01-22 15:28:52 +01:00
|
|
|
this.modalController.dismiss();
|
2022-03-18 11:45:38 +01:00
|
|
|
this.deleteRecording();
|
2021-01-22 15:28:52 +01:00
|
|
|
}
|
2021-01-26 15:18:03 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
doRefresh(ev: any) {
|
2021-03-12 17:35:54 +01:00
|
|
|
this.getRoomInfo();
|
2021-01-27 16:01:49 +01:00
|
|
|
ev.target.complete();
|
2021-01-26 15:18:03 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
getGroupContacts(room: any) {
|
2021-01-27 16:01:49 +01:00
|
|
|
this.showLoader = true;
|
2021-01-19 16:10:40 +01:00
|
|
|
//If group is private call getGroupMembers
|
2022-03-03 08:21:22 +01:00
|
|
|
if (this.room.t === 'p') {
|
|
|
|
|
this.chatService.getGroupMembers(this.roomId).subscribe(res => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-01-19 16:10:40 +01:00
|
|
|
this.members = res['members'];
|
2021-01-27 16:01:49 +01:00
|
|
|
this.showLoader = false;
|
2021-01-19 16:10:40 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//Otherwise call getChannelMembers for públic groups
|
2022-03-03 08:21:22 +01:00
|
|
|
else {
|
|
|
|
|
this.chatService.getChannelMembers(this.roomId).subscribe(res => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-01-19 16:10:40 +01:00
|
|
|
this.members = res['members'];
|
2021-01-27 16:01:49 +01:00
|
|
|
this.showLoader = false;
|
2021-01-19 16:10:40 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-19 18:54:50 +01:00
|
|
|
|
2021-08-20 17:00:48 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
showDateDuration(start: any) {
|
2021-09-06 16:53:58 +01:00
|
|
|
return this.timeService.showDateDuration(start);
|
2021-10-28 15:40:41 +01:00
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
countDownDate(date: any, roomId: string) {
|
2021-11-03 15:35:01 +01:00
|
|
|
this.roomCountDownDate = this.timeService.countDownDate(date, roomId);
|
|
|
|
|
return this.timeService.countDownDateTimer(date, roomId);
|
2021-08-20 17:00:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addZero(i) {
|
|
|
|
|
if (i < 10) {
|
|
|
|
|
i = "0" + i;
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
sendMessage() {
|
|
|
|
|
this.wsChatMethodsService.getGroupRoom(this.roomId).send({})
|
|
|
|
|
}
|
2021-08-20 17:00:48 +01:00
|
|
|
|
2022-03-21 21:09:05 +01:00
|
|
|
base64toBlob(base64Data, contentType) {
|
|
|
|
|
contentType = contentType || '';
|
|
|
|
|
var sliceSize = 1024;
|
|
|
|
|
var byteCharacters = atob(base64Data);
|
|
|
|
|
var bytesLength = byteCharacters.length;
|
|
|
|
|
var slicesCount = Math.ceil(bytesLength / sliceSize);
|
|
|
|
|
var byteArrays = new Array(slicesCount);
|
|
|
|
|
|
|
|
|
|
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
2022-04-05 13:22:17 +01:00
|
|
|
var begin = sliceIndex * sliceSize;
|
|
|
|
|
var end = Math.min(begin + sliceSize, bytesLength);
|
2022-03-21 21:09:05 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
var bytes = new Array(end - begin);
|
|
|
|
|
for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
|
|
|
|
|
bytes[i] = byteCharacters[offset].charCodeAt(0);
|
|
|
|
|
}
|
|
|
|
|
byteArrays[sliceIndex] = new Uint8Array(bytes);
|
2022-03-21 21:09:05 +01:00
|
|
|
}
|
|
|
|
|
return new Blob(byteArrays, { type: contentType });
|
2022-04-05 13:22:17 +01:00
|
|
|
}
|
2022-03-21 21:09:05 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
async sendAudio(fileName) {
|
2022-03-18 11:45:38 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
const roomId = this.roomId
|
2022-03-21 21:09:05 +01:00
|
|
|
let audioFile;
|
2022-03-18 11:45:38 +01:00
|
|
|
this.storage.get('recordData').then((recordData) => {
|
2022-04-18 15:27:16 +01:00
|
|
|
|
2022-03-21 21:09:05 +01:00
|
|
|
audioFile = recordData;
|
2022-04-05 13:22:17 +01:00
|
|
|
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
|
2022-03-24 17:40:14 +01:00
|
|
|
this.audioRecorded = recordData?.value?.recordDataBase64;
|
2022-03-18 11:45:38 +01:00
|
|
|
}
|
2022-04-18 15:24:01 +01:00
|
|
|
else if(recordData?.value?.mimeType && recordData?.value?.recordDataBase64){
|
2022-03-24 17:40:14 +01:00
|
|
|
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
2022-03-18 11:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
//Converting base64 to blob
|
|
|
|
|
const encodedData = btoa(this.audioRecorded);
|
|
|
|
|
const blob = this.base64toBlob(encodedData, recordData.value.mimeType)
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
2022-03-14 17:11:00 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(roomId).send({
|
|
|
|
|
file: {
|
|
|
|
|
"type": "application/audio",
|
|
|
|
|
"msDuration": audioFile.value.msDuration,
|
|
|
|
|
"mimeType": audioFile.value.mimeType,
|
|
|
|
|
},
|
|
|
|
|
attachments: [{
|
|
|
|
|
"title": fileName,
|
|
|
|
|
"title_link_download": true,
|
|
|
|
|
"type": "audio"
|
|
|
|
|
}],
|
|
|
|
|
temporaryData: formData
|
|
|
|
|
})
|
2021-08-20 17:00:48 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
});
|
2022-03-21 21:09:05 +01:00
|
|
|
this.deleteRecording();
|
2020-12-28 10:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
|
2021-04-15 23:57:14 +01:00
|
|
|
async openOptions() {
|
2021-04-21 15:14:43 +01:00
|
|
|
const modal = await this.popoverController.create({
|
2020-12-28 10:11:00 +01:00
|
|
|
component: ChatPopoverPage,
|
|
|
|
|
cssClass: 'chat-popover',
|
2021-01-20 13:17:54 +01:00
|
|
|
componentProps: {
|
2021-04-15 23:57:14 +01:00
|
|
|
roomId: this.roomId,
|
2022-01-27 14:26:18 +01:00
|
|
|
members: this.members,
|
2022-07-01 14:28:57 +01:00
|
|
|
isAdmin: this.isAdmin,
|
2021-01-20 13:17:54 +01:00
|
|
|
},
|
2020-12-28 10:11:00 +01:00
|
|
|
});
|
2021-04-15 23:57:14 +01:00
|
|
|
await modal.present();
|
2022-03-03 08:21:22 +01:00
|
|
|
modal.onDidDismiss().then(res => {
|
|
|
|
|
if (res.data == 'leave') {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-01-27 14:26:18 +01:00
|
|
|
//this.wsChatMethodsService.subscribeToRoomUpdate(this.roomId, this.room);
|
2021-04-20 17:18:57 +01:00
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
else if (res.data == 'cancel') {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-04-21 15:14:43 +01:00
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
else if (res.data == 'edit') {
|
2021-08-17 14:17:19 +01:00
|
|
|
this.editGroup(this.roomId);
|
|
|
|
|
}
|
2021-01-20 16:58:04 +01:00
|
|
|
});
|
2020-12-28 10:11:00 +01:00
|
|
|
}
|
2021-04-21 15:14:43 +01:00
|
|
|
|
2021-09-13 12:37:58 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
viewDocument(file: any, url?: string) {
|
2021-10-09 20:55:05 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
if (file.type == "application/webtrix") {
|
2021-10-09 20:55:05 +01:00
|
|
|
this.openViewDocumentModal(file);
|
2021-10-05 16:29:33 +01:00
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
else {
|
2021-10-09 20:55:05 +01:00
|
|
|
let fullUrl = "https://www.tabularium.pt" + url;
|
|
|
|
|
this.fileService.viewDocumentByUrl(fullUrl);
|
2021-10-05 16:29:33 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
async openViewDocumentModal(file: any) {
|
2021-10-09 20:24:34 +01:00
|
|
|
|
|
|
|
|
let task = {
|
|
|
|
|
serialNumber: '',
|
|
|
|
|
taskStartDate: '',
|
|
|
|
|
isEvent: true,
|
|
|
|
|
workflowInstanceDataFields: {
|
|
|
|
|
FolderID: '',
|
|
|
|
|
Subject: file.Assunto,
|
|
|
|
|
SourceSecFsID: file.ApplicationId,
|
|
|
|
|
SourceType: 'DOC',
|
|
|
|
|
SourceID: file.DocId,
|
|
|
|
|
DispatchNumber: ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let doc = {
|
2022-03-03 08:21:22 +01:00
|
|
|
"Id": "",
|
|
|
|
|
"ParentId": "",
|
|
|
|
|
"Source": 1,
|
|
|
|
|
"ApplicationId": file.ApplicationId,
|
|
|
|
|
"CreateDate": "",
|
|
|
|
|
"Data": null,
|
|
|
|
|
"Description": "",
|
|
|
|
|
"Link": null,
|
|
|
|
|
"SourceId": file.DocId,
|
|
|
|
|
"SourceName": file.Assunto,
|
|
|
|
|
"Stakeholders": "",
|
2021-10-09 20:24:34 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-05 16:29:33 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewDocumentPage,
|
|
|
|
|
componentProps: {
|
2021-10-09 20:24:34 +01:00
|
|
|
trustedUrl: '',
|
|
|
|
|
file: {
|
|
|
|
|
title: file.Assunto,
|
|
|
|
|
url: '',
|
|
|
|
|
title_link: '',
|
|
|
|
|
},
|
|
|
|
|
Document: doc,
|
|
|
|
|
applicationId: file.ApplicationId,
|
|
|
|
|
docId: file.DocId,
|
|
|
|
|
folderId: '',
|
|
|
|
|
task: task
|
2021-10-05 16:29:33 +01:00
|
|
|
},
|
2021-10-09 20:24:34 +01:00
|
|
|
cssClass: 'modal modal-desktop'
|
2021-10-05 16:29:33 +01:00
|
|
|
});
|
|
|
|
|
await modal.present();
|
2021-10-09 20:24:34 +01:00
|
|
|
|
2021-09-14 16:34:50 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-21 14:05:59 +01:00
|
|
|
async bookMeeting() {
|
2022-03-03 08:21:22 +01:00
|
|
|
this.attendees = this.members.map((val) => {
|
2021-09-21 14:05:59 +01:00
|
|
|
return {
|
|
|
|
|
Name: val.name,
|
2022-03-03 08:21:22 +01:00
|
|
|
EmailAddress: val.username + "@" + environment.domain,
|
2021-09-21 14:05:59 +01:00
|
|
|
IsRequired: "true",
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-09-21 14:05:59 +01:00
|
|
|
this.popoverController.dismiss();
|
2022-03-03 08:21:22 +01:00
|
|
|
if (window.innerWidth <= 1024) {
|
2021-09-21 14:05:59 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: NewEventPage,
|
2022-03-03 08:21:22 +01:00
|
|
|
componentProps: {
|
2021-09-21 14:05:59 +01:00
|
|
|
attendees: this.attendees,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'modal modal-desktop',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((data) => {
|
2022-03-03 08:21:22 +01:00
|
|
|
if (data) {
|
2021-09-21 14:05:59 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-09 15:09:47 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
|
|
|
|
|
async takePicture() {
|
|
|
|
|
const roomId = this.roomId
|
2022-02-09 15:09:47 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
const image = await this.CameraService.takePicture();
|
2022-02-04 07:42:43 +01:00
|
|
|
await this.fileService.saveImage(image)
|
|
|
|
|
const lastphoto: any = await this.fileService.loadFiles();
|
2022-03-03 08:21:22 +01:00
|
|
|
const { capturedImage, capturedImageTitle } = await this.fileService.loadFileData(lastphoto);
|
2022-02-07 17:55:00 +01:00
|
|
|
const base64 = await fetch(capturedImage);
|
|
|
|
|
const blob = await base64.blob();
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-09 15:09:47 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(roomId).send({
|
2022-02-04 00:22:35 +01:00
|
|
|
file: {
|
|
|
|
|
"type": "application/img",
|
2022-02-08 17:44:15 +01:00
|
|
|
"guid": ''
|
2022-02-04 00:22:35 +01:00
|
|
|
},
|
2022-02-07 20:18:48 +01:00
|
|
|
temporaryData: formData,
|
2022-02-04 00:22:35 +01:00
|
|
|
attachments: [{
|
2022-03-03 08:21:22 +01:00
|
|
|
"title": capturedImageTitle,
|
2022-02-04 00:57:46 +01:00
|
|
|
"text": "description",
|
2022-02-04 00:22:35 +01:00
|
|
|
"title_link_download": false,
|
|
|
|
|
}]
|
|
|
|
|
})
|
|
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
}
|
2022-02-09 15:09:47 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
async addImage() {
|
|
|
|
|
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
|
|
|
|
|
}
|
2022-02-09 15:09:47 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
async addFile() {
|
|
|
|
|
this.addFileToChat(['.doc', '.docx', '.pdf'])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async addFileWebtrix() {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: SearchPage,
|
|
|
|
|
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
|
|
|
|
|
componentProps: {
|
|
|
|
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
|
|
|
|
select: true,
|
|
|
|
|
showSearchInput: true,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
2022-03-03 08:21:22 +01:00
|
|
|
modal.onDidDismiss().then(async res => {
|
2022-02-03 21:01:53 +01:00
|
|
|
const data = res.data;
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
if (data.selected) {
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-09 15:09:47 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(this.roomId).send({
|
2022-03-03 08:21:22 +01:00
|
|
|
file: {
|
2022-02-03 21:01:53 +01:00
|
|
|
"name": res.data.selected.Assunto,
|
|
|
|
|
"type": "application/webtrix",
|
|
|
|
|
"ApplicationId": res.data.selected.ApplicationType,
|
|
|
|
|
"DocId": res.data.selected.Id,
|
|
|
|
|
"Assunto": res.data.selected.Assunto,
|
|
|
|
|
},
|
2022-04-06 16:25:47 +01:00
|
|
|
temporaryData: res,
|
2022-02-04 00:22:35 +01:00
|
|
|
attachments: [{
|
|
|
|
|
"title": res.data.selected.Assunto,
|
|
|
|
|
"description": res.data.selected.DocTypeDesc,
|
|
|
|
|
// "title_link": url_no_options,
|
|
|
|
|
"title_link_download": true,
|
|
|
|
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
|
|
|
|
// "message_link": url_no_options,
|
2022-02-04 08:00:10 +01:00
|
|
|
"type": "webtrix",
|
2022-02-07 17:55:00 +01:00
|
|
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
2022-02-04 08:00:10 +01:00
|
|
|
"text": res.data.selected.DocTypeDesc,
|
|
|
|
|
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
2022-02-03 21:01:53 +01:00
|
|
|
}]
|
|
|
|
|
})
|
2022-02-04 00:22:35 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
async addFileToChat(types: typeof FileType[]) {
|
2022-03-03 08:21:22 +01:00
|
|
|
|
|
|
|
|
const roomId = this.roomId
|
|
|
|
|
|
2022-02-07 13:41:27 +01:00
|
|
|
const file: any = await this.fileService.getFileFromDevice(types);
|
2022-02-04 00:22:35 +01:00
|
|
|
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-02-09 15:09:47 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
|
2022-04-05 13:22:17 +01:00
|
|
|
|
|
|
|
|
const encodedData = btoa(JSON.stringify(await this.getBase64(file)));
|
2022-04-06 16:25:47 +01:00
|
|
|
const blob = this.base64toBlob(encodedData, file.type)
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append('blobFile', blob);
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
|
|
|
|
|
this.wsChatMethodsService.getGroupRoom(roomId).send({
|
|
|
|
|
file: {
|
|
|
|
|
"type": file.type,
|
|
|
|
|
"guid": '',
|
|
|
|
|
},
|
|
|
|
|
attachments: [{
|
|
|
|
|
"title": file.name,
|
|
|
|
|
"name": file.name,
|
|
|
|
|
// "text": "description",
|
|
|
|
|
"title_link_download": false,
|
|
|
|
|
}],
|
|
|
|
|
temporaryData: formData
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getFileReader(): FileReader {
|
|
|
|
|
const fileReader = new FileReader();
|
|
|
|
|
const zoneOriginalInstance = (fileReader as any)["__zone_symbol__originalInstance"];
|
|
|
|
|
return zoneOriginalInstance || fileReader;
|
|
|
|
|
}
|
2022-02-04 00:22:35 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
getBase64(file) {
|
|
|
|
|
var reader = this.getFileReader();
|
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
reader.onload = function () {
|
|
|
|
|
resolve(reader.result)
|
|
|
|
|
};
|
|
|
|
|
reader.onerror = function (error) {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
};
|
|
|
|
|
});
|
2022-03-03 08:21:22 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
}
|
2022-02-09 15:09:47 +01:00
|
|
|
|
2021-06-03 15:50:12 +01:00
|
|
|
async openChatOptions(ev?: any) {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
const roomId = this.roomId;
|
2021-08-18 09:23:53 +01:00
|
|
|
|
2020-12-29 12:40:19 +01:00
|
|
|
const popover = await this.popoverController.create({
|
|
|
|
|
component: ChatOptionsPopoverPage,
|
|
|
|
|
cssClass: 'chat-options-popover',
|
|
|
|
|
event: ev,
|
2021-01-20 10:23:59 +01:00
|
|
|
componentProps: {
|
2021-01-20 13:17:54 +01:00
|
|
|
room: this.room,
|
2021-08-18 09:23:53 +01:00
|
|
|
members: this.members,
|
|
|
|
|
eventSelectedDate: new Date(),
|
2021-01-20 10:23:59 +01:00
|
|
|
},
|
2020-12-29 12:40:19 +01:00
|
|
|
translucent: true
|
|
|
|
|
});
|
2021-09-13 12:37:58 +01:00
|
|
|
await popover.present();
|
2022-03-03 08:21:22 +01:00
|
|
|
await popover.onDidDismiss().then(async (res) => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-02-04 08:00:10 +01:00
|
|
|
if (res['data'] == 'meeting') {
|
2021-09-21 14:05:59 +01:00
|
|
|
this.bookMeeting();
|
2021-09-13 12:37:58 +01:00
|
|
|
}
|
2022-02-04 08:00:10 +01:00
|
|
|
else if (res['data'] == 'take-picture') {
|
|
|
|
|
this.takePicture()
|
2021-09-21 14:05:59 +01:00
|
|
|
}
|
2022-02-04 08:00:10 +01:00
|
|
|
else if (res['data'] == 'add-picture') {
|
2022-02-03 21:01:53 +01:00
|
|
|
this.addImage()
|
|
|
|
|
|
2021-09-21 14:05:59 +01:00
|
|
|
}
|
2022-02-04 08:00:10 +01:00
|
|
|
else if (res['data'] == 'add-document') {
|
2022-02-03 21:01:53 +01:00
|
|
|
this.addFile()
|
2021-09-21 14:05:59 +01:00
|
|
|
}
|
2022-02-04 08:00:10 +01:00
|
|
|
else if (res['data'] == 'documentoGestaoDocumental') {
|
2021-09-21 14:05:59 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
this.addFileWebtrix()
|
2021-09-14 10:30:13 +01:00
|
|
|
}
|
2021-09-13 12:37:58 +01:00
|
|
|
});
|
2020-12-29 12:40:19 +01:00
|
|
|
}
|
2021-08-18 18:58:02 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
async addContacts() {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2020-12-29 12:40:19 +01:00
|
|
|
const modal = await this.modalController.create({
|
2021-01-21 16:27:04 +01:00
|
|
|
component: GroupContactsPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
isCreated: this.isGroupCreated,
|
|
|
|
|
room: this.room,
|
2021-01-26 11:03:00 +01:00
|
|
|
members: this.members,
|
|
|
|
|
name: this.room.name,
|
2021-07-23 14:43:51 +01:00
|
|
|
},
|
2020-12-29 12:40:19 +01:00
|
|
|
cssClass: 'contacts',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await modal.present();
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
modal.onDidDismiss().then(() => {
|
2021-03-12 17:35:54 +01:00
|
|
|
this.getRoomInfo();
|
2021-01-26 15:18:03 +01:00
|
|
|
});
|
2020-12-29 12:40:19 +01:00
|
|
|
}
|
2021-03-12 11:56:54 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
async editGroup(roomId) {
|
2021-08-17 14:17:19 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: EditGroupPage,
|
|
|
|
|
cssClass: 'modal modal-desktop',
|
|
|
|
|
componentProps: {
|
|
|
|
|
roomId: roomId,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
2022-03-03 08:21:22 +01:00
|
|
|
modal.onDidDismiss().then((res) => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-09-21 14:28:53 +01:00
|
|
|
this.getRoomInfo();
|
|
|
|
|
//this.modalController.dismiss(res.data);
|
2021-08-17 14:17:19 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-27 11:23:57 +01:00
|
|
|
/* async actionSheet() {
|
|
|
|
|
const actionSheet = await this.actionSheetController.create({
|
|
|
|
|
cssClass: 'my-custom-class',
|
|
|
|
|
buttons: [{
|
|
|
|
|
text: 'Sair do grupo',
|
|
|
|
|
handler: () => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-01-27 11:23:57 +01:00
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
text: 'Alterar nome do grupo1',
|
|
|
|
|
handler: () => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-01-27 11:23:57 +01:00
|
|
|
this.openChangeGroupName()
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
text: 'Apagar o grupo',
|
|
|
|
|
handler: () => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2021-01-27 11:23:57 +01:00
|
|
|
}
|
2021-07-23 14:43:51 +01:00
|
|
|
},
|
2021-01-27 11:23:57 +01:00
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
await actionSheet.present();
|
|
|
|
|
}
|
|
|
|
|
*/
|
2020-12-28 10:11:00 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
getRoomMessageDB(roomId) {
|
|
|
|
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
|
|
|
} else {
|
|
|
|
|
this.sqlservice.getAllChatMSG(roomId).then((msg: any) => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
let chatmsgArray = [];
|
|
|
|
|
let array = []
|
|
|
|
|
msg.forEach(element => {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
|
|
|
|
|
let msgChat = {
|
|
|
|
|
_id: element.Id,
|
|
|
|
|
attachments: this.isJson(element.Attachments),
|
|
|
|
|
channels: this.isJson(element.Channels),
|
|
|
|
|
file: this.isJson(element.File),
|
|
|
|
|
mentions: this.isJson(element.Mentions),
|
|
|
|
|
msg: element.Msg,
|
|
|
|
|
rid: element.Rid,
|
|
|
|
|
ts: element.Ts,
|
|
|
|
|
u: this.isJson(element.U),
|
|
|
|
|
_updatedAt: element.UpdatedAt,
|
|
|
|
|
image_url: this.isJson(element.image_url)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chatmsgArray.push(msgChat)
|
|
|
|
|
});
|
|
|
|
|
|
2022-01-29 20:39:35 +01:00
|
|
|
// this.messages = chatmsgArray;
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isJson(str) {
|
|
|
|
|
try {
|
|
|
|
|
JSON.parse(str);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return JSON.parse(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transformDataMSG(res) {
|
|
|
|
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
|
|
|
} else {
|
|
|
|
|
res.forEach(element => {
|
|
|
|
|
|
|
|
|
|
let chatmsg = {
|
|
|
|
|
_id: element._id,
|
|
|
|
|
attachments: element.attachments,
|
|
|
|
|
channels: element.channels,
|
|
|
|
|
file: element.file,
|
|
|
|
|
mentions: element.mentions,
|
|
|
|
|
msg: element.msg,
|
|
|
|
|
rid: element.rid,
|
|
|
|
|
ts: element.ts,
|
|
|
|
|
u: element.u,
|
|
|
|
|
_updatedAt: element._updatedAt,
|
|
|
|
|
/* image_url: {
|
|
|
|
|
name: name,
|
|
|
|
|
path: `${IMAGE_DIR}/${name}`,
|
|
|
|
|
data: `data:image/jpeg;base64,${readFile.data}`,
|
|
|
|
|
}, */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.sqlservice.addChatMSG(chatmsg)
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
async serverLongPull() {
|
2021-07-26 19:31:19 +01:00
|
|
|
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(async res => {
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
if (res == 502) {
|
|
|
|
|
// Connection timeout
|
|
|
|
|
// happens when the connection was pending for too long
|
|
|
|
|
// let's reconnect
|
|
|
|
|
await this.serverLongPull();
|
|
|
|
|
} else if (res != 200) {
|
|
|
|
|
// Show Error
|
|
|
|
|
//showMessage(response.statusText);
|
|
|
|
|
//this.loadMessages()
|
|
|
|
|
let msgOnly = res['messages'].filter(data => data.t != 'au');
|
|
|
|
|
//this.messages = msgOnly.reverse();
|
2022-04-28 09:32:27 +01:00
|
|
|
//
|
2022-03-03 08:21:22 +01:00
|
|
|
this.transformDataMSG(msgOnly.reverse());
|
|
|
|
|
this.getRoomMessageDB(this.roomId);
|
|
|
|
|
// Reconnect in one second
|
|
|
|
|
if (this.route.url != "/home/chat") {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
} else {
|
|
|
|
|
//Check if modal is opened
|
|
|
|
|
if (document.querySelector('.isGroupChatOpened')) {
|
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
|
|
|
await this.serverLongPull();
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
}
|
2021-08-19 18:54:50 +01:00
|
|
|
}
|
2021-07-26 20:52:03 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
} else {
|
|
|
|
|
// Got message
|
|
|
|
|
//let message = await response.text();
|
|
|
|
|
//this.loadMessages()
|
|
|
|
|
await this.serverLongPull();
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-07-26 19:31:19 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-17 15:34:15 +01:00
|
|
|
sliderOpts = {
|
|
|
|
|
zoom: false,
|
|
|
|
|
slidesPerView: 1.5,
|
|
|
|
|
spaceBetween: 20,
|
|
|
|
|
centeredSlides: true
|
|
|
|
|
};
|
|
|
|
|
zoomActive = false;
|
2022-03-03 08:21:22 +01:00
|
|
|
zoomScale = 1;
|
|
|
|
|
|
|
|
|
|
sliderZoomOpts = {
|
|
|
|
|
allowSlidePrev: false,
|
|
|
|
|
allowSlideNext: false,
|
|
|
|
|
zoom: {
|
|
|
|
|
maxRatio: 5
|
|
|
|
|
},
|
|
|
|
|
on: {
|
|
|
|
|
zoomChange: (scale, imageEl, slideEl) => {
|
|
|
|
|
this.zoomActive = true;
|
|
|
|
|
this.zoomScale = scale / 5;
|
|
|
|
|
this.changeDetectorRef.detectChanges();
|
|
|
|
|
}
|
2021-11-17 15:34:15 +01:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-08 20:27:05 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
async touchEnd(zoomslides: IonSlides, card) {
|
|
|
|
|
// Zoom back to normal
|
|
|
|
|
const slider = await zoomslides.getSwiper();
|
|
|
|
|
const zoom = slider.zoom;
|
|
|
|
|
zoom.out();
|
2021-12-08 20:27:05 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
// Card back to normal
|
|
|
|
|
card.el.style['z-index'] = 9;
|
2021-12-08 20:27:05 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
this.zoomActive = false;
|
|
|
|
|
this.changeDetectorRef.detectChanges();
|
|
|
|
|
}
|
2021-12-08 20:27:05 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
touchStart(card) {
|
|
|
|
|
// Make card appear above backdrop
|
|
|
|
|
card.el.style['z-index'] = 11;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
b64toBlob(b64Data, contentType) {
|
|
|
|
|
contentType = contentType || '';
|
|
|
|
|
var sliceSize = 512;
|
|
|
|
|
b64Data = b64Data.replace(/^[^,]+,/, '');
|
|
|
|
|
b64Data = b64Data.replace(/\s/g, '');
|
|
|
|
|
var byteCharacters = window.atob(b64Data);
|
|
|
|
|
var byteArrays = [];
|
|
|
|
|
|
|
|
|
|
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
|
|
|
var slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
|
|
|
|
|
|
|
|
var byteNumbers = new Array(slice.length);
|
|
|
|
|
for (var i = 0; i < slice.length; i++) {
|
|
|
|
|
byteNumbers[i] = slice.charCodeAt(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var byteArray = new Uint8Array(byteNumbers);
|
|
|
|
|
|
|
|
|
|
byteArrays.push(byteArray);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var blob = new Blob(byteArrays, { type: contentType });
|
|
|
|
|
return blob;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-06 17:02:42 +01:00
|
|
|
openFile(pdfString, filename, type) {
|
2022-04-05 13:22:17 +01:00
|
|
|
const blob = this.b64toBlob(pdfString, 'application/pdf')
|
|
|
|
|
let pathFile = ''
|
|
|
|
|
const fileName = filename
|
|
|
|
|
const contentFile = blob
|
|
|
|
|
if (this.platform.is('ios')) {
|
|
|
|
|
pathFile = this.file.documentsDirectory
|
|
|
|
|
} else {
|
|
|
|
|
pathFile = this.file.externalRootDirectory
|
|
|
|
|
}
|
2022-04-28 09:32:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
this.file
|
|
|
|
|
.writeFile(pathFile, fileName, contentFile, { replace: true })
|
|
|
|
|
.then(success => {
|
|
|
|
|
this.fileOpener
|
|
|
|
|
.open(pathFile + fileName, 'application/pdf')
|
2022-04-28 09:32:27 +01:00
|
|
|
.then(() => console.log())
|
|
|
|
|
.catch(e => console.error(e))
|
2022-04-05 13:22:17 +01:00
|
|
|
})
|
2022-04-28 09:32:27 +01:00
|
|
|
.catch(e => console.error(e))
|
2022-04-05 13:22:17 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-22 16:11:30 +01:00
|
|
|
downloadFileMsg(msg: MessageService) {
|
|
|
|
|
msg.downloadFileMsg()
|
2022-01-13 17:28:35 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
downloadFileFromBrowser(fileName: string, data: any): void {
|
|
|
|
|
const linkSource = data;
|
|
|
|
|
const downloadLink = document.createElement("a");
|
|
|
|
|
downloadLink.href = linkSource;
|
|
|
|
|
downloadLink.download = fileName;
|
|
|
|
|
downloadLink.click();
|
|
|
|
|
}
|
2022-01-21 16:55:05 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
async openPreview(msg: MessageService) {
|
2022-01-21 16:55:05 +01:00
|
|
|
|
2022-07-12 14:57:02 +01:00
|
|
|
if(msg?.file?.type === "application/webtrix") {
|
2022-04-06 16:25:47 +01:00
|
|
|
this.viewDocument(msg.file, msg.attachments.image_url)
|
2022-03-03 08:21:22 +01:00
|
|
|
} else {
|
2022-04-06 16:25:47 +01:00
|
|
|
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
|
|
|
|
|
this.downloadFileMsg(msg)
|
2022-04-07 15:22:25 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
} else {
|
2022-04-07 15:22:25 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
var str = msg.attachments[0].image_url;
|
|
|
|
|
str = str.substring(1, ((str.length) - 1));
|
2022-04-07 15:22:25 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
2022-04-07 15:22:25 +01:00
|
|
|
|
2022-07-12 14:57:02 +01:00
|
|
|
if (msg?.file?.type == "application/img") {
|
2022-07-06 17:02:42 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewMediaPage,
|
|
|
|
|
cssClass: 'modal modal-desktop',
|
|
|
|
|
componentProps: {
|
|
|
|
|
image: msg.attachments[0].image_url,
|
|
|
|
|
type: msg.file.type,
|
|
|
|
|
username: msg.u.name,
|
|
|
|
|
_updatedAt: msg._updatedAt
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
modal.present();
|
|
|
|
|
} else {
|
|
|
|
|
this.downloadFileFromBrowser(msg.attachments[0].name, str)
|
|
|
|
|
}
|
2022-04-07 15:22:25 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
} else {
|
2022-07-06 17:02:42 +01:00
|
|
|
if (msg.file.type == "application/img") {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewMediaPage,
|
|
|
|
|
cssClass: 'modal modal-desktop',
|
|
|
|
|
componentProps: {
|
|
|
|
|
image: msg.attachments[0].image_url,
|
|
|
|
|
type: msg.file.type,
|
|
|
|
|
username: msg.u.name,
|
|
|
|
|
_updatedAt: msg._updatedAt
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
modal.present();
|
|
|
|
|
} else {
|
|
|
|
|
this.openFile(str, msg.attachments[0].name, msg.file.type);
|
|
|
|
|
}
|
2022-04-06 16:25:47 +01:00
|
|
|
}
|
2022-04-05 13:22:17 +01:00
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
}
|
2022-01-21 16:55:05 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
}
|
2022-03-21 21:09:05 +01:00
|
|
|
|
|
|
|
|
async audioPreview(msg) {
|
2022-04-28 09:32:27 +01:00
|
|
|
|
2022-03-21 21:09:05 +01:00
|
|
|
if (!msg.attachments[0].title_link || msg.attachments[0].title_link === null || msg.attachments[0].title_link === '') {
|
|
|
|
|
this.downloadFileMsg(msg)
|
2022-04-05 13:22:17 +01:00
|
|
|
} else { }
|
2022-03-21 21:09:05 +01:00
|
|
|
}
|
2021-03-12 13:10:20 +01:00
|
|
|
}
|
2021-11-17 15:34:15 +01:00
|
|
|
|