From ce357b786213c584a2e40ad20dbcd6f33060e5fa Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 21 Mar 2022 21:36:50 +0100 Subject: [PATCH 01/21] svae --- src/app/services/chat/room.service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index f7f9bbd7f..53344c4c1 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -363,7 +363,6 @@ export class RoomService { this.messages.splice(index, 1) - if (SessionStore.user.RochetChatUser == message.u.username) { const allMemberThatIsOffline = this.getAllMemberThatIsOffline() @@ -418,7 +417,6 @@ export class RoomService { (response: any) => { message.delateRequest = true message.save() - this.deleteMessage(msgId) }, (response) => { From c4c4355c950148d4099fab0f1dbf56e9b58bc37a Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Tue, 22 Mar 2022 14:23:38 +0100 Subject: [PATCH 02/21] improve --- .../group-messages/group-messages.page.ts | 45 ++++++++------ src/app/pages/chat/messages/messages.page.ts | 46 ++++++++------ src/app/services/chat/room.service.ts | 62 ++++++++++--------- .../group-messages/group-messages.page.ts | 54 +++++++++------- .../shared/chat/messages/messages.page.html | 2 +- src/app/shared/chat/messages/messages.page.ts | 55 +++++++++------- 6 files changed, 151 insertions(+), 113 deletions(-) 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 fc233c102..859065b17 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.ts +++ b/src/app/pages/chat/group-messages/group-messages.page.ts @@ -252,15 +252,19 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { this.lastAudioRecorded = fileName; }) - this.storage.get('recordData').then((recordData) => { - console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); - } - else{ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); - } - }); + try { + this.storage.get('recordData').then((recordData) => { + console.log(recordData); + if(recordData.value.recordDataBase64.includes('data:audio')){ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); + } + else{ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); + } + }); + } catch (error) {} + + } startRecording() { @@ -431,15 +435,20 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { async sendAudio(fileName) { const roomId = this.roomId - this.storage.get('recordData').then((recordData) => { - console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = recordData.value.recordDataBase64; - } - else{ - this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; - } - }); + + try { + + this.storage.get('recordData').then((recordData) => { + console.log(recordData); + if(recordData.value.recordDataBase64.includes('data:audio')){ + this.audioRecorded = recordData.value.recordDataBase64; + } + else{ + this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; + } + }); + } catch (error) {} + //Converting base64 to blob const base64Response = await fetch(this.audioRecorded); diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 217ccbc57..75ae06f9c 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -205,15 +205,19 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.lastAudioRecorded = fileName; }) - this.storage.get('recordData').then((recordData) => { - console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); - } - else{ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); - } - }); + try { + this.storage.get('recordData').then((recordData) => { + console.log(recordData); + if(recordData.value.recordDataBase64.includes('data:audio')){ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); + } + else{ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); + } + }); + } catch (error) {} + + } startRecording() { @@ -367,17 +371,21 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { } async sendAudio(fileName) { - const roomId = this.roomId - this.storage.get('recordData').then((recordData) => { - console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = recordData.value.recordDataBase64; - } - else{ - this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; - } - }); + try { + + this.storage.get('recordData').then((recordData) => { + console.log(recordData); + if(recordData.value.recordDataBase64.includes('data:audio')){ + this.audioRecorded = recordData.value.recordDataBase64; + } + else{ + this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; + } + }); + } catch (error) {} + + //Converting base64 to blob const base64Response = await fetch(this.audioRecorded); diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 53344c4c1..bd46ff5a4 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -255,7 +255,7 @@ export class RoomService { // alert('delete') // console.log(args[0], 'receive delete message::()') - this.deleteMessage(args[1]?.method?._id) + // this.deleteMessage(args[1]?.method?._id) } else { // alert('miss') @@ -357,36 +357,43 @@ export class RoomService { * @description delete message in the view * @param id message ID */ - async deleteMessage(id) { - await this.messages.forEach(async(message, index) => { - if(message._id == id) { - - this.messages.splice(index, 1) - - if (SessionStore.user.RochetChatUser == message.u.username) { - const allMemberThatIsOffline = this.getAllMemberThatIsOffline() + async deleteMessage(_id) { + + const id = _id + + for (let i =0; i <= this.messages.length; i++) { + + console.log('message._id == id',this.messages[i]?._id, id, i, this.messages[i]?._id == id) + + if(this.messages[i]?._id == id ) { + + this.messages.splice(i, 1) - await DeleteMessageModel.create({ - messageId: message._id, - rid: message.rid, - ts: message.ts, - u: message.u, - needToReceiveBy: allMemberThatIsOffline - }) - } - - message.delateStatusFalse() - message.delateDB() + if (SessionStore.user.RochetChatUser == this.messages[i].u.username) { + const allMemberThatIsOffline = this.getAllMemberThatIsOffline() + + DeleteMessageModel.create({ + messageId: this.messages[i]._id, + rid: this.messages[i].rid, + ts: this.messages[i].ts, + u: this.messages[i].u, + needToReceiveBy: allMemberThatIsOffline + }) + } + + this.messages[i].delateStatusFalse() + this.messages[i].delateDB() + + //Get previous last message from room + const previousLastMessage = this.messages.slice(-1)[0]; + + this.lastMessage = previousLastMessage; + this.calDateDuration(previousLastMessage._updatedAt) + this.sortRoomList() - //Get previous last message from room - const previousLastMessage = this.messages.slice(-1)[0]; - - this.lastMessage = previousLastMessage; - this.calDateDuration(previousLastMessage._updatedAt) - this.sortRoomList() } - }) + } } @@ -424,7 +431,6 @@ export class RoomService { // alert('not found') this.deleteMessage(msgId) } else { - // this.deleteMessage(DeletedMessageId) this.WsChatService.registerCallback({ type: 'reConnect', funx: async ()=> { diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index 245533836..875afc895 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -274,20 +274,23 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe } async loadFiles() { + try { + this.storage.get('fileName').then((fileName) => { + this.lastAudioRecorded = fileName; + }) + + this.storage.get('recordData').then((recordData) => { + console.log(recordData); + if(recordData.value.recordDataBase64.includes('data:audio')){ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); + } + else{ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); + } + }); + } catch (error) {} - this.storage.get('fileName').then((fileName) => { - this.lastAudioRecorded = fileName; - }) - - this.storage.get('recordData').then((recordData) => { - console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); - } - else{ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); - } - }); + } startRecording() { @@ -418,18 +421,23 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe } async sendAudio(fileName) { - const roomId = this.roomId - this.storage.get('recordData').then((recordData) => { - console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = recordData.value.recordDataBase64; - } - else{ - this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; - } - }); + + + try { + this.storage.get('recordData').then((recordData) => { + console.log(recordData); + if(recordData.value.recordDataBase64.includes('data:audio')){ + this.audioRecorded = recordData.value.recordDataBase64; + } + else{ + this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; + } + }); + } catch (error) {} + + //Converting base64 to blob const base64Response = await fetch(this.audioRecorded); const blob = await base64Response.blob(); diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index f2b691ed3..faee008e0 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -50,7 +50,7 @@
- {{msg.msg}} + {{msg.msg}} {{msg._id}} Apagou a mensagem diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index 320a7ff46..a27d82756 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -250,20 +250,23 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy } async loadFiles() { + try { + this.storage.get('fileName').then((fileName) => { + this.lastAudioRecorded = fileName; + }) + + this.storage.get('recordData').then((recordData) => { + console.log(recordData); + if(recordData.value.recordDataBase64.includes('data:audio')){ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); + } + else{ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); + } + }); + } catch (error) {} - this.storage.get('fileName').then((fileName) => { - this.lastAudioRecorded = fileName; - }) - - this.storage.get('recordData').then((recordData) => { - console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); - } - else{ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); - } - }); + } startRecording() { @@ -355,19 +358,23 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy } async sendAudio(fileName) { - const roomId = this.roomId let audioFile; - this.storage.get('recordData').then((recordData) => { - console.log(recordData); - audioFile = recordData; - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = recordData.value.recordDataBase64; - } - else{ - this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; - } - }); + + try { + + this.storage.get('recordData').then((recordData) => { + // console.log(recordData); + audioFile = recordData; + if(recordData.value.recordDataBase64.includes('data:audio')){ + this.audioRecorded = recordData.value.recordDataBase64; + } + else{ + this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; + } + }); + } catch (error) {} + //Converting base64 to blob const base64Response = await fetch(this.audioRecorded); From 6960333d0aab296ec55254603a198f94be6ece0d Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Wed, 23 Mar 2022 22:01:59 +0100 Subject: [PATCH 03/21] save --- src/app/services/chat/room.service.ts | 61 +++++----- .../group-messages/group-messages.page.html | 114 +++++++++--------- .../shared/chat/messages/messages.page.html | 21 ++-- src/app/shared/chat/messages/messages.page.ts | 1 - 4 files changed, 101 insertions(+), 96 deletions(-) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 89d279ab6..045c4cdf8 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -360,40 +360,41 @@ export class RoomService { * @param id message ID */ async deleteMessage(_id) { - + alert('delete!!!') const id = _id for (let i =0; i <= this.messages.length; i++) { - console.log('message._id == id',this.messages[i]?._id, id, i, this.messages[i]?._id == id) - if(this.messages[i]?._id == id ) { - this.messages.splice(i, 1) + // console.log(_id,'==',this.messages[i]?._id, true) + this.messages.splice(i, 1) + + if (SessionStore.user.RochetChatUser == this.messages[i].u.username) { + const allMemberThatIsOffline = this.getAllMemberThatIsOffline() - if (SessionStore.user.RochetChatUser == this.messages[i].u.username) { - const allMemberThatIsOffline = this.getAllMemberThatIsOffline() - - DeleteMessageModel.create({ - messageId: this.messages[i]._id, - rid: this.messages[i].rid, - ts: this.messages[i].ts, - u: this.messages[i].u, - needToReceiveBy: allMemberThatIsOffline - }) - } - - this.messages[i].delateStatusFalse() - this.messages[i].delateDB() - - //Get previous last message from room - const previousLastMessage = this.messages.slice(-1)[0]; - - this.lastMessage = previousLastMessage; - this.calDateDuration(previousLastMessage._updatedAt) - this.sortRoomList() + DeleteMessageModel.create({ + messageId: this.messages[i]._id, + rid: this.messages[i].rid, + ts: this.messages[i].ts, + u: this.messages[i].u, + needToReceiveBy: allMemberThatIsOffline + }) + } + + this.messages[i].delateDB() + //Get previous last message from room + const previousLastMessage = this.messages.slice(-1)[0]; + this.lastMessage = previousLastMessage; + this.calDateDuration(previousLastMessage._updatedAt) + this.sortRoomList() + + return true + + } else { + console.log(_id,'==',this.messages[i]?._id, false) } } @@ -420,18 +421,24 @@ export class RoomService { async sendDeleteRequest(msgId) { const message = this.messages.find((e)=>e._id = msgId) - message.delateStatusFalse() + // await message.delateStatusFalse() this.ChatMethodsService.deleteMessage({_id:msgId, msgId:msgId, roomId:message.rid}).subscribe( (response: any) => { + + const message = this.messages.find((e)=>e._id = msgId) message.delateRequest = true message.save() + }, (response) => { if (response.error.error.startsWith('No message found with the id of')) { - // alert('not found') + this.deleteMessage(msgId) + const message = this.messages.find((e)=>e._id = msgId) + message.delateRequest = true + } else { this.WsChatService.registerCallback({ type: 'reConnect', diff --git a/src/app/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html index ec38e0b7e..356ff82c3 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.html +++ b/src/app/shared/chat/group-messages/group-messages.page.html @@ -60,73 +60,71 @@
-
-
-
-
- - - - -
-
- {{msg.u.name}} - {{msg.duration}} -
-
-
-
-
- image - -
-
-
-
- - - - - - - {{file.title}} +
+
+
+
+ + + + +
+
+ {{msg.u.name}} + {{msg.duration}} +
+
+
+
+
+ image + +
+
+
+
+ + + + + + + {{file.title}} +
+
+ + + {{file.title}} + + + +
+
+ +
+
+ + {{file.description}} + + {{msg.displayType}} +
-
- - - {{file.title}} - - - -
-
- -
-
- - {{file.description}} - - {{msg.displayType}} -
+ {{last ? scrollToBottom() : ''}}
- {{last ? scrollToBottom() : ''}}
+
+ {{msg.u.name}} criou esta reunião
+
+ De {{showDateDuration(msg.file.start_date)}} a {{showDateDuration(msg.file.end_date)}}
+ {{msg.file.venue}}
+
-
- {{msg.u.name}} criou esta reunião
-
- De {{showDateDuration(msg.file.start_date)}} a {{showDateDuration(msg.file.end_date)}}
- {{msg.file.venue}}
-
-
-
- Apagou a mensagem -
+
diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 03901b8ea..1cc280109 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -45,12 +45,12 @@
- {{msg.u.name}} + {{msg.u.name}} {{msg.delateRequest}} {{msg.duration}}
- {{msg.msg}} {{msg._id}} + {{msg.msg}} Apagou a mensagem @@ -75,7 +75,7 @@
- {{msg.u.name}} + {{msg.u.name}} {{msg.delateRequest}} {{msg.duration}}
@@ -141,24 +141,25 @@
- {{msg.u.name}} criou esta reunião
-
- + De {{showDateDuration(msg.file.start_date)}} a {{showDateDuration(msg.file.end_date)}}
- + {{msg.file.venue}}
-
- Apagou a mensagem -
+
diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index 561c3b6a7..c7ebdc2db 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -416,7 +416,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy deleteMessage(msgId: string, msg:MessageService) { - msg.delateStatusFalse() this.wsChatMethodsService.getDmRoom(this.roomId).sendDeleteRequest(msgId) } From d05f9fdf77b3a8c57118ddf00ff576a327a17083 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Wed, 23 Mar 2022 23:00:19 +0100 Subject: [PATCH 04/21] fix bug --- src/app/services/chat/message.service.ts | 2 +- src/app/services/chat/room.service.ts | 18 ++++++++++-------- .../shared/chat/messages/messages.page.html | 6 +++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 3dd75d4a3..1b016202c 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -69,7 +69,7 @@ export class MessageService { this.channels = channels || [] this.mentions = mentions || [] - this.msg = msg || "" + this.msg = msg || " " this.rid = rid this.ts = ts this.u = u || { name: this.usernameToDisplayName(SessionStore.user.RochetChatUser), username: SessionStore.user.RochetChatUser, _id: ""} diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 045c4cdf8..ceedb63f6 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -257,7 +257,7 @@ export class RoomService { // alert('delete') // console.log(args[0], 'receive delete message::()') - // this.deleteMessage(args[1]?.method?._id) + this.deleteMessage(args[1]?.method?._id) } else { // alert('miss') @@ -360,20 +360,22 @@ export class RoomService { * @param id message ID */ async deleteMessage(_id) { - alert('delete!!!') + const id = _id for (let i =0; i <= this.messages.length; i++) { if(this.messages[i]?._id == id ) { - // console.log(_id,'==',this.messages[i]?._id, true) + + + console.log(_id,'==',this.messages[i]?._id, true) this.messages.splice(i, 1) if (SessionStore.user.RochetChatUser == this.messages[i].u.username) { const allMemberThatIsOffline = this.getAllMemberThatIsOffline() - DeleteMessageModel.create({ + await DeleteMessageModel.create({ messageId: this.messages[i]._id, rid: this.messages[i].rid, ts: this.messages[i].ts, @@ -382,7 +384,7 @@ export class RoomService { }) } - this.messages[i].delateDB() + await this.messages[i].delateDB() //Get previous last message from room const previousLastMessage = this.messages.slice(-1)[0]; @@ -420,13 +422,13 @@ export class RoomService { async sendDeleteRequest(msgId) { - const message = this.messages.find((e)=>e._id = msgId) + const message = this.messages.find((e)=>e._id == msgId) // await message.delateStatusFalse() this.ChatMethodsService.deleteMessage({_id:msgId, msgId:msgId, roomId:message.rid}).subscribe( (response: any) => { - const message = this.messages.find((e)=>e._id = msgId) + const message = this.messages.find((e)=>e._id == msgId) message.delateRequest = true message.save() @@ -436,7 +438,7 @@ export class RoomService { if (response.error.error.startsWith('No message found with the id of')) { this.deleteMessage(msgId) - const message = this.messages.find((e)=>e._id = msgId) + const message = this.messages.find((e)=>e._id == msgId) message.delateRequest = true } else { diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 1cc280109..0b6fbaf43 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -35,7 +35,7 @@
+ *ngFor="let msg of wsChatMethodsService.getDmRoom(roomId).messages; index as i; let last = last">
@@ -45,7 +45,7 @@
- {{msg.u.name}} {{msg.delateRequest}} + {{msg.u.name}} {{msg.duration}}
@@ -75,7 +75,7 @@
- {{msg.u.name}} {{msg.delateRequest}} + {{msg.u.name}} {{msg.duration}}
From 7d646a4873391d882090d7300015ddbef5cc17d9 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Wed, 23 Mar 2022 23:01:03 +0100 Subject: [PATCH 05/21] fixe bug --- src/app/services/chat/room.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index ceedb63f6..113fd11f4 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -423,7 +423,7 @@ export class RoomService { async sendDeleteRequest(msgId) { const message = this.messages.find((e)=>e._id == msgId) - // await message.delateStatusFalse() + await message.delateStatusFalse() this.ChatMethodsService.deleteMessage({_id:msgId, msgId:msgId, roomId:message.rid}).subscribe( (response: any) => { From c369273830c8cd046a0ce7209c40bf6f04c8ab10 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Wed, 23 Mar 2022 23:01:40 +0100 Subject: [PATCH 06/21] fixe bug --- src/app/services/chat/room.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 113fd11f4..5e4028fcd 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -428,7 +428,6 @@ export class RoomService { this.ChatMethodsService.deleteMessage({_id:msgId, msgId:msgId, roomId:message.rid}).subscribe( (response: any) => { - const message = this.messages.find((e)=>e._id == msgId) message.delateRequest = true message.save() @@ -438,7 +437,7 @@ export class RoomService { if (response.error.error.startsWith('No message found with the id of')) { this.deleteMessage(msgId) - const message = this.messages.find((e)=>e._id == msgId) + message.delateRequest = true } else { From b80c2070f4a47646b357f38dd6102ebec6ebc561 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Wed, 23 Mar 2022 23:08:49 +0100 Subject: [PATCH 07/21] fixe bug --- src/app/services/chat/message.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 1b016202c..3dd75d4a3 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -69,7 +69,7 @@ export class MessageService { this.channels = channels || [] this.mentions = mentions || [] - this.msg = msg || " " + this.msg = msg || "" this.rid = rid this.ts = ts this.u = u || { name: this.usernameToDisplayName(SessionStore.user.RochetChatUser), username: SessionStore.user.RochetChatUser, _id: ""} From 71ecf0ded36df3b35505c07551e4995598c671de Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Thu, 24 Mar 2022 16:28:47 +0100 Subject: [PATCH 08/21] save --- src/app/services/chat/room.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 5e4028fcd..bbed55b36 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -430,6 +430,7 @@ export class RoomService { message.delateRequest = true message.save() + this.deleteMessage(msgId) }, (response) => { @@ -437,7 +438,6 @@ export class RoomService { if (response.error.error.startsWith('No message found with the id of')) { this.deleteMessage(msgId) - message.delateRequest = true } else { From 02950aeca069336410ff5d1d928cec70914ed5c8 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Thu, 24 Mar 2022 16:30:18 +0100 Subject: [PATCH 09/21] fix --- src/app/services/chat/message.service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 3dd75d4a3..eb57debc5 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -110,8 +110,6 @@ export class MessageService { this.displayType = this.file.type.replace('application/','').toUpperCase() } - this.downloadFileMsg() - } this.calDateDuration() From 7ef93a2aff1e512f8fbbee15be4bb683d6268ee3 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Thu, 24 Mar 2022 17:40:14 +0100 Subject: [PATCH 10/21] fix chat rooms list --- .../group-messages/group-messages.page.ts | 69 ++++++++++--------- src/app/pages/chat/messages/messages.page.ts | 12 ++-- src/app/services/auth.service.ts | 2 + src/app/services/chat/message.service.ts | 1 + src/app/services/chat/room.service.ts | 14 ++-- .../group-messages/group-messages.page.ts | 12 ++-- src/app/shared/chat/messages/messages.page.ts | 12 ++-- 7 files changed, 65 insertions(+), 57 deletions(-) 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 0fb93ec00..c2dd76e6e 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.ts +++ b/src/app/pages/chat/group-messages/group-messages.page.ts @@ -254,11 +254,11 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { try { this.storage.get('recordData').then((recordData) => { console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); + if(recordData?.value?.recordDataBase64.includes('data:audio')){ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64); } else{ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`); } }); } catch (error) {} @@ -266,6 +266,36 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { } + stopRecording() { + this.deleteRecording(); + this.allowTyping = false; + console.log('Stop'); + if (!this.recording) { + return; + } + this.recording = false; + VoiceRecorder.stopRecording().then(async (result: RecordingData) => { + console.log('==================================',result); + + this.recording = false; + if (result.value && result.value.recordDataBase64) { + const recordData = result.value.recordDataBase64; + //console.log(recordData); + const fileName = new Date().getTime() + ".mp3"; + //Save file + await this.storage.set('fileName',fileName) + this.storage.set('recordData',result).then(() => { + console.log('Audio recorded saved', result); + + setTimeout(async () => { + this.loadFiles(); + }, 1000); + }) + } + }) + + } + startRecording() { console.log('Recording'); @@ -277,32 +307,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { this.calculateDuration(); } - stopRecording() { - this.deleteRecording(); - this.allowTyping = false; - console.log('Stop'); - if (!this.recording) { - return; - } - this.recording = false; - VoiceRecorder.stopRecording().then(async (result: RecordingData) => { - console.log(result); - this.recording = false; - if (result.value && result.value.recordDataBase64) { - const recordData = result.value.recordDataBase64; - //console.log(recordData); - const fileName = new Date().getTime() + ".mp3"; - //Save file - this.storage.set('fileName',fileName); - this.storage.set('recordData',result).then(() => { - console.log('Audio recorded saved'); - }) - } - }) - setTimeout(async () => { - this.loadFiles(); - }, 1000); - } + async deleteRecording(){ this.storage.remove('fileName'); @@ -458,11 +463,11 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { this.storage.get('recordData').then((recordData) => { console.log(recordData); audioFile = recordData; - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = recordData.value.recordDataBase64; + if(recordData?.value?.recordDataBase64.includes('data:audio')){ + this.audioRecorded = recordData?.value?.recordDataBase64; } else{ - this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; + this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`; } //Converting base64 to blob diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 110e45d2c..236932ab4 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -208,11 +208,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { try { this.storage.get('recordData').then((recordData) => { console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); + if(recordData?.value?.recordDataBase64.includes('data:audio')){ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64); } else{ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`); } }); } catch (error) {} @@ -397,11 +397,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { this.storage.get('recordData').then((recordData) => { console.log(recordData); audioFile = recordData; - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = recordData.value.recordDataBase64; + if(recordData?.value?.recordDataBase64.includes('data:audio')){ + this.audioRecorded = recordData?.value?.recordDataBase64; } else{ - this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; + this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`; } //Converting base64 to blob diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index a9c989a6c..779457497 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -169,6 +169,8 @@ export class AuthService { try { let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise() message.file.guid = guid.path + + console.log('========================================',guid) // await this.storage.set(guid.path, message.file.image_url).then(() => { // console.log('add picture to chat IMAGE SAVED') // // message.getFileFromDb() diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index eb57debc5..3c5e5e934 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -245,6 +245,7 @@ export class MessageService { ts: this.attachments[0].ts } + console.log(this.attachments) // save the changes to the storage this.save() } diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index bbed55b36..3d0ebedef 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -371,6 +371,13 @@ export class RoomService { console.log(_id,'==',this.messages[i]?._id, true) this.messages.splice(i, 1) + + //Get previous last message from room + const previousLastMessage = this.messages.slice(-1)[0]; + this.lastMessage = previousLastMessage; + + this.calDateDuration(previousLastMessage._updatedAt) + this.sortRoomList() if (SessionStore.user.RochetChatUser == this.messages[i].u.username) { const allMemberThatIsOffline = this.getAllMemberThatIsOffline() @@ -386,13 +393,6 @@ export class RoomService { await this.messages[i].delateDB() - //Get previous last message from room - const previousLastMessage = this.messages.slice(-1)[0]; - - this.lastMessage = previousLastMessage; - this.calDateDuration(previousLastMessage._updatedAt) - this.sortRoomList() - return true } else { diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index 7687b6519..8c340283a 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -281,11 +281,11 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe this.storage.get('recordData').then((recordData) => { console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); + if(recordData?.value?.recordDataBase64.includes('data:audio')){ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64); } else{ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`); } }); } catch (error) {} @@ -447,11 +447,11 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe this.storage.get('recordData').then((recordData) => { console.log(recordData); audioFile = recordData; - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = recordData.value.recordDataBase64; + if(recordData?.value?.recordDataBase64.includes('data:audio')){ + this.audioRecorded = recordData?.value?.recordDataBase64; } else{ - this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; + this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`; } diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index c7ebdc2db..3e3b4afd3 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -256,11 +256,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy this.storage.get('recordData').then((recordData) => { console.log(recordData); - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64); + if(recordData?.value?.recordDataBase64.includes('data:audio')){ + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64); } else{ - this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`); + this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`); } }); } catch (error) {} @@ -382,11 +382,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy this.storage.get('recordData').then((recordData) => { console.log(recordData); audioFile = recordData; - if(recordData.value.recordDataBase64.includes('data:audio')){ - this.audioRecorded = recordData.value.recordDataBase64; + if(recordData?.value?.recordDataBase64.includes('data:audio')){ + this.audioRecorded = recordData?.value?.recordDataBase64; } else{ - this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`; + this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`; } //Converting base64 to blob From c9267f808ec2b26b160337ca2c87f2e64fbf6c8b Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Thu, 24 Mar 2022 17:58:20 +0100 Subject: [PATCH 11/21] save --- src/environments/environment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/environments/environment.ts b/src/environments/environment.ts index cd809f519..8737cf097 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,8 +4,8 @@ export const environment = { production: false, - apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', - //apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', + //apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', + apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/', apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket', //apiChatUrl: 'https://www.tabularium.pt/api/v1/', From 7bb81f17eaad4a6750bd4889630524367bee85ae Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Fri, 25 Mar 2022 11:05:51 +0100 Subject: [PATCH 12/21] save --- src/environments/environment.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 8737cf097..934547196 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -6,10 +6,11 @@ export const environment = { production: false, //apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', - apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/', - apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket', - //apiChatUrl: 'https://www.tabularium.pt/api/v1/', - /* apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', */ + /* apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/', + apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket', */ + apiChatUrl: 'https://www.tabularium.pt/api/v1/', + apiWsChatUrl: 'wss://www.tabularium.pt/websocket', + //apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', domain: 'gabinetedigital.local', //gabinetedigital.local defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto paulo.pinto@gabinetedigital.local defaultuserpwd: 'tabteste@006', //tabteste@006, From 160015c878e37a3eb38acbb9b945925370f8bcdc Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Fri, 25 Mar 2022 12:25:17 +0100 Subject: [PATCH 13/21] comment add file option --- .../group-messages/group-messages.page.html | 8 ++++---- .../shared/chat/messages/messages.page.html | 18 +++++++++--------- .../chat-options-popover.page.html | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/app/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html index 356ff82c3..72961fdaa 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.html +++ b/src/app/shared/chat/group-messages/group-messages.page.html @@ -124,8 +124,8 @@ {{msg.file.venue}}
- - + +
Alterou o nome do grupo para "{{msg.msg.split('-').join(' ')}}"
@@ -214,9 +214,9 @@ - + diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 0b6fbaf43..b7f8692cf 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -49,12 +49,12 @@ {{msg.duration}}
- - {{msg.msg}} + + {{msg.msg}} Apagou a mensagem - + @@ -84,7 +84,7 @@
image - + @@ -127,7 +127,7 @@ {{msg.displayType}} - + @@ -163,7 +163,7 @@
- + @@ -174,7 +174,7 @@ - +
- + diff --git a/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html b/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html index 33bebb685..88a4ba92e 100644 --- a/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html +++ b/src/app/shared/popover/chat-options-popover/chat-options-popover.page.html @@ -7,7 +7,7 @@
- +
From f2cf3163299e38a73db9a806f4a421e6b391f3a0 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Fri, 25 Mar 2022 14:32:15 +0100 Subject: [PATCH 14/21] save --- src/app/services/chat/message.service.ts | 2 +- src/app/services/chat/room.service.ts | 6 ++---- src/environments/environment.ts | 26 ++++++++++++++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 3c5e5e934..908bfd4cf 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -143,7 +143,7 @@ export class MessageService { this.uploadingFile = false - if(uploadSuccessfully || this.hasSendAttachment == false) { + if(uploadSuccessfully) { this.hasSendAttachment = true this.errorUploadingAttachment = false this.temporaryData = {} diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 3d0ebedef..138093304 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -367,8 +367,6 @@ export class RoomService { if(this.messages[i]?._id == id ) { - - console.log(_id,'==',this.messages[i]?._id, true) this.messages.splice(i, 1) @@ -382,7 +380,7 @@ export class RoomService { if (SessionStore.user.RochetChatUser == this.messages[i].u.username) { const allMemberThatIsOffline = this.getAllMemberThatIsOffline() - await DeleteMessageModel.create({ + DeleteMessageModel.create({ messageId: this.messages[i]._id, rid: this.messages[i].rid, ts: this.messages[i].ts, @@ -391,7 +389,7 @@ export class RoomService { }) } - await this.messages[i].delateDB() + this.messages[i].delateDB() return true diff --git a/src/environments/environment.ts b/src/environments/environment.ts index cd809f519..b3c070ea0 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,17 +3,31 @@ // The list of file replacements can be found in `angular.json`. export const environment = { + production: false, - apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', - //apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', - apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/', - apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket', - //apiChatUrl: 'https://www.tabularium.pt/api/v1/', - /* apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', */ + + //apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', + + apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', + + /* apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/', + + apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket', */ + + apiChatUrl: 'https://www.tabularium.pt/api/v1/', + + apiWsChatUrl: 'wss://www.tabularium.pt/websocket', + + //apiChatUrl: 'http://chat.gabinetedigital.local:3000/api/v1/', + domain: 'gabinetedigital.local', //gabinetedigital.local + defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto paulo.pinto@gabinetedigital.local + defaultuserpwd: 'tabteste@006', //tabteste@006, + chatOffline: true + }; /* From e2721f10919da8d76e7eccdcda7923fb3d2b3b1a Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Fri, 25 Mar 2022 17:39:51 +0100 Subject: [PATCH 15/21] fix --- src/app/services/chat/message.service.ts | 12 +++++++----- src/app/services/chat/room.service.ts | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 908bfd4cf..838c0ea51 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -77,17 +77,21 @@ export class MessageService { this._id = _id this._updatedAt = _updatedAt || new Date().getTime() this.file = file - this.attachments = attachments this.temporaryData = temporaryData this.localReference = localReference || null this.id = id this.delate = delate this.delateRequest = delateRequest + if(this.attachments?.length >= 1 && attachments?.length >= 1) { + this.attachments[0] = Object.assign(this.attachments[0], attachments[0]) + } else { + this.attachments = attachments + } + this.viewed = [...new Set([...viewed,...this.viewed])]; this.received = [...new Set([...received,...this.received])]; - - + if(!this.ts) { this.offline = true this.messageSend = false @@ -105,11 +109,9 @@ export class MessageService { } if(this.hasFile) { - if(this.file.type != 'application/webtrix') { this.displayType = this.file.type.replace('application/','').toUpperCase() } - } this.calDateDuration() diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 138093304..5dd8c4a0c 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -238,7 +238,6 @@ export class RoomService { const args = message.fields.args - // alert(JSON.stringify(args)) if (typeof args[1] != 'object') { @@ -367,8 +366,7 @@ export class RoomService { if(this.messages[i]?._id == id ) { - console.log(_id,'==',this.messages[i]?._id, true) - this.messages.splice(i, 1) + //Get previous last message from room const previousLastMessage = this.messages.slice(-1)[0]; @@ -377,7 +375,7 @@ export class RoomService { this.calDateDuration(previousLastMessage._updatedAt) this.sortRoomList() - if (SessionStore.user.RochetChatUser == this.messages[i].u.username) { + if (SessionStore.user.RochetChatUser == this.messages[i]?.u?.username) { const allMemberThatIsOffline = this.getAllMemberThatIsOffline() DeleteMessageModel.create({ @@ -389,7 +387,10 @@ export class RoomService { }) } - this.messages[i].delateDB() + this.messages[i]?.delateDB() + + console.log(_id,'==',this.messages[i]?._id, true) + this.messages.splice(i, 1) return true From 313314f3a5843b3deca09314dc82b6965bc892b4 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Sat, 26 Mar 2022 08:52:33 +0100 Subject: [PATCH 16/21] fix --- src/app/services/chat/room.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 5dd8c4a0c..910c80f1e 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -270,7 +270,12 @@ export class RoomService { getRoomMembersIds(): string[] { - return this.members.map((user)=> user._id) + try { + return this.members.map((user)=> user._id) + } catch(error) { + return [] + } + } getAllMemberThatIsNotOffline(): string[] { From ee496965e118f63b7bfb2214155084bce104746b Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Sun, 27 Mar 2022 15:18:54 +0100 Subject: [PATCH 17/21] fix bug --- .../group-messages/group-messages.page.html | 5 ++- .../group-messages/group-messages.page.ts | 4 +-- src/app/services/chat/message.service.ts | 35 ++++++++----------- .../group-messages/group-messages.page.html | 6 +++- .../group-messages/group-messages.page.ts | 6 ++-- .../shared/chat/messages/messages.page.html | 2 +- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/app/pages/chat/group-messages/group-messages.page.html b/src/app/pages/chat/group-messages/group-messages.page.html index e8b83b138..28b5366ad 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.html +++ b/src/app/pages/chat/group-messages/group-messages.page.html @@ -102,7 +102,10 @@
-
+
+ NOT UPLOADED +
+
image
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 c2dd76e6e..d10e4cf45 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.ts +++ b/src/app/pages/chat/group-messages/group-messages.page.ts @@ -276,7 +276,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { this.recording = false; VoiceRecorder.stopRecording().then(async (result: RecordingData) => { console.log('==================================',result); - + this.recording = false; if (result.value && result.value.recordDataBase64) { const recordData = result.value.recordDataBase64; @@ -293,7 +293,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { }) } }) - + } startRecording() { diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 3c5e5e934..453c0f899 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -24,10 +24,10 @@ export class MessageService { msg = '' rid = '' ts = {} - - u = { - name: '', - username: '', + + u = { + name: '', + username: '', _id: "" } @@ -105,7 +105,7 @@ export class MessageService { } if(this.hasFile) { - + if(this.file.type != 'application/webtrix') { this.displayType = this.file.type.replace('application/','').toUpperCase() } @@ -129,7 +129,7 @@ export class MessageService { if(!this.hasFile) { const params = {roomId:this.rid, msg:this.msg, localReference: this.localReference} - + await this.sendRequest(params) } else { @@ -143,7 +143,7 @@ export class MessageService { this.uploadingFile = false - if(uploadSuccessfully || this.hasSendAttachment == false) { + if(uploadSuccessfully ) { this.hasSendAttachment = true this.errorUploadingAttachment = false this.temporaryData = {} @@ -169,7 +169,7 @@ export class MessageService { return new Promise((resolve, reject)=>{ reject(false) }) - + } } @@ -193,13 +193,8 @@ export class MessageService { this.WsChatService.registerCallback({ type: 'reConnect', funx: async ()=> { - - this.WsChatService.send(params).then(({message, requestId}) => { - let ChatMessage = message.result - this.messageSend = true - this.redefinedMessage(ChatMessage) - - }) + + this.sendRequest(params) return true } }) @@ -209,7 +204,7 @@ export class MessageService { async redefinedMessage(ChatMessage , update = true) { ChatMessage = this.NfService.fix_updatedAt(ChatMessage) - + const message = this.getChatObj() ChatMessage = Object.assign(message, ChatMessage) @@ -244,7 +239,7 @@ export class MessageService { title_link_download: this.attachments[0].title_link_download, ts: this.attachments[0].ts } - + console.log(this.attachments) // save the changes to the storage this.save() @@ -264,7 +259,7 @@ export class MessageService { } async delateDB() { - + // alert('delete data') const message = await MessageModel.get({_id: this._id}) await message.delete() @@ -284,8 +279,8 @@ export class MessageService { return { channels: this.channels, mentions: this.mentions, - //msg: this.AESEncrypt.encrypt(this.msg, SessionStore.user.RochetChatUser), - msg:this.msg, + //msg: this.AESEncrypt.encrypt(this.msg, SessionStore.user.RochetChatUser), + msg:this.msg, rid: this.rid, ts: this.ts, u: this.u, diff --git a/src/app/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html index 72961fdaa..e9cf98ea0 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.html +++ b/src/app/shared/chat/group-messages/group-messages.page.html @@ -76,7 +76,11 @@
-
+
+ NOT UPLOADED +
+
image
diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index 8c340283a..829ce53d3 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -278,7 +278,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe this.storage.get('fileName').then((fileName) => { this.lastAudioRecorded = fileName; }) - + this.storage.get('recordData').then((recordData) => { console.log(recordData); if(recordData?.value?.recordDataBase64.includes('data:audio')){ @@ -290,7 +290,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe }); } catch (error) {} - + } startRecording() { @@ -454,7 +454,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`; } - + //Converting base64 to blob const encodedData = btoa(this.audioRecorded); const blob = this.base64toBlob(encodedData, recordData.value.mimeType) diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index b7f8692cf..7ec469275 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -84,7 +84,6 @@
image - @@ -144,6 +143,7 @@ Apagou a mensagem
+ {{msg.u.name}} criou esta reunião