Adicionou {{user.name}}
@@ -231,24 +281,24 @@
-
+
{{ ChatSystemService.getGroupRoom(roomId).userThatIsTyping }} está a escrever...
-
-
+
+
@@ -256,28 +306,39 @@
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
+
\ No newline at end of file
diff --git a/src/app/pages/chat/group-messages/group-messages.page.ts b/src/app/pages/chat/group-messages/group-messages.page.ts
index ad3a7aeae..e243c7405 100644
--- a/src/app/pages/chat/group-messages/group-messages.page.ts
+++ b/src/app/pages/chat/group-messages/group-messages.page.ts
@@ -31,6 +31,7 @@ import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
import { SessionStore } from 'src/app/store/session.service';
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
+import { RouteService } from 'src/app/services/route.service';
@Component({
selector: 'app-group-messages',
templateUrl: './group-messages.page.html',
@@ -80,7 +81,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
durationDisplay = '';
duration = 0;
showAvatar = true;
- audioPermissionStatus: 'granted'| 'denied' | 'prompt' | null = null
+ audioPermissionStatus: 'granted' | 'denied' | 'prompt' | null = null
sessionStore = SessionStore
isAdmin = false;
constructor(
@@ -102,6 +103,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
private sanitiser: DomSanitizer,
private file: File,
private fileOpener: FileOpener,
+ public RouteService: RouteService,
) {
this.ChatSystemService.getUser()
@@ -114,10 +116,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
};
- this.ChatSystemService.getGroupRoom(this.roomId).loadHistory({});
- this.ChatSystemService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked;
- this.ChatSystemService.openRoom(this.roomId)
- this.groupNameFormart = this.ChatSystemService.getGroupRoom(this.roomId).name.split('-').join(' ')
+ this.open();
setTimeout(() => {
this.scrollToBottomClicked()
@@ -133,6 +132,20 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
+ open() {
+ try {
+ this.ChatSystemService.getGroupRoom(this.roomId).loadHistory({});
+ this.ChatSystemService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked;
+ this.ChatSystemService.openRoom(this.roomId)
+ this.groupNameFormart = this.ChatSystemService.getGroupRoom(this.roomId).name.split('-').join(' ')
+
+ } catch (error) {
+ setTimeout(() => {
+ this.open()
+ }, 3000)
+ }
+ }
+
ngOnInit() {
this.loggedUser = this.loggedUserChat;
@@ -166,7 +179,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.scrollChangeCallback = () => this.onContentScrolled(event);
window.addEventListener('scroll', this.scrollChangeCallback, true);
- if(this.room?.customFields?.countDownDate) {
+ if (this.room?.customFields?.countDownDate) {
this.roomCountDownDate = this.timeService.countDownDate(this.room.customFields.countDownDate, this.room._id);
}
}
@@ -249,7 +262,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64);
}
- else if(recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
+ else if (recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`);
}
});
@@ -290,22 +303,22 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
async startRecording() {
VoiceRecorder.requestAudioRecordingPermission();
- if(await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) =>{return result.value})){
- if(await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => {return result.value})){
+ 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();
+ if (this.recording) {
+ return;
+ }
+ this.recording = true;
+ VoiceRecorder.startRecording();
+ this.calculateDuration();
//}
}
- else{
+ else {
this.toastService._badRequest('Para gravar uma mensagem de voz, permita o acesso do Gabinete Digital ao seu microfone.');
}
}
- else{
+ else {
this.toastService._badRequest('Este dispositivo não tem capacidade para gravação de áudio!');
}
}
@@ -388,7 +401,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
- if(SessionStore.user.ChatData.data.userId == this.room.u._id){
+ if (SessionStore.user.ChatData.data.userId == this.room.u._id) {
this.isAdmin = true
} else {
this.isAdmin = false
@@ -534,7 +547,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
else if (res.data == 'edit') {
this.editGroup(this.roomId);
- } else if (res.data == 'addUser') {
+ } else if (res.data == 'addUser') {
this.addContacts();
} else if (res.data == 'delete') {
@@ -796,7 +809,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
_getBase64(file) {
- return new Promise((resolve, reject)=>{
+ return new Promise((resolve, reject) => {
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
@@ -806,7 +819,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
console.log('Error: ', error);
};
})
- }
+ }
async addFileToChat(types: typeof FileType[]) {
@@ -818,7 +831,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
- const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => {
+ const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch((error) => {
console.error(error);
})));
const blob = this.fileService.base64toBlob(encodedData, file.type)
@@ -909,7 +922,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}
async addContacts() {
- if(this.isAdmin) {
+ if (this.isAdmin) {
const modal = await this.modalController.create({
component: GroupContactsPage,
@@ -1011,7 +1024,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
} else {
//Check if modal is opened
if (document.querySelector('.isGroupChatOpened')) {
- await new Promise(resolve => setTimeout(resolve, 5000)).catch ((error) => {
+ await new Promise(resolve => setTimeout(resolve, 5000)).catch((error) => {
console.error(error);
});
await this.serverLongPull();
@@ -1100,9 +1113,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
}).then((dir) => {
console.log('DIR ', dir)
this.fileOpener
- .open(dir.uri, type)
- .then(() => console.log())
- .catch(e => console.error(e))
+ .open(dir.uri, type)
+ .then(() => console.log())
+ .catch(e => console.error(e))
});
}
@@ -1120,7 +1133,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
async openPreview(msg: MessageService) {
- if(msg?.file?.type === "application/webtrix") {
+ if (msg?.file?.type === "application/webtrix") {
this.viewDocument(msg.file, msg.attachments.image_url)
} else {
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
@@ -1197,11 +1210,11 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
// set the bytes of the buffer to the correct values
for (var i = 0; i < byteString.length; i++) {
- ia[i] = byteString.charCodeAt(i);
+ ia[i] = byteString.charCodeAt(i);
}
// write the ArrayBuffer to a blob, and you're done
- var blob = new Blob([ab], {type: mimeString});
+ var blob = new Blob([ab], { type: mimeString });
return blob;
}
diff --git a/src/app/pages/chat/messages/messages.page.html b/src/app/pages/chat/messages/messages.page.html
index f7ab9fe1d..2d5982a83 100644
--- a/src/app/pages/chat/messages/messages.page.html
+++ b/src/app/pages/chat/messages/messages.page.html
@@ -1,4 +1,4 @@
-
+