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) }