This commit is contained in:
Peter Maquiran
2022-02-10 21:27:48 +01:00
parent 55d42cb2fc
commit dddc41bc80
5 changed files with 20 additions and 11 deletions
+11 -7
View File
@@ -96,10 +96,10 @@ export class RoomService {
console.log('recivemessage', _ChatMessage)
alert('receive and send to view')
setTimeout(()=>{
let ChatMessage = _ChatMessage.fields.args[0]
ChatMessage = this.fix_updatedAt(ChatMessage)
let ChatMessage = _ChatMessage.fields.args[0]
ChatMessage = this.fix_updatedAt(ChatMessage)
if(!this.messagesLocalReference.includes(ChatMessage.localReference)) {
const message = this.prepareMessage(ChatMessage)
this.lastMessage = message
this.calDateDuration(ChatMessage._updatedAt)
@@ -121,7 +121,8 @@ export class RoomService {
setTimeout(()=>{
this.scrollDown()
}, 50)
}, 150)
}
}
)
@@ -404,9 +405,12 @@ export class RoomService {
} else {
if(environment.chatOffline) alert('create offline')
const offlineMessage = this.prepareMessage(ChatMessage)
this.messagesLocalReference.push(offlineMessage.localReference)
offlineMessage.send().then(()=>{
this.updateMessageDB(ChatMessage, ChatMessage.localReference)
})
}
});
@@ -437,7 +441,7 @@ export class RoomService {
await chatHistory.result.messages.reverse().forEach( async (message) => {
this.prepareMessage(message)
this.messages = this.sortService.sortDate(this.messages, '_updatedAt')
// this.messages = this.sortService.sortDate(this.messages, '_updatedAt')
})
@@ -459,7 +463,7 @@ export class RoomService {
wewMessage.setData(message)
wewMessage.loadHistory = this.hasLoadHistory
if(!message._id && environment.chatOffline) {
if(!message._id && environment.chatOffline && save) {
if(this.hasLoadHistory && environment.chatOffline) alert('create offline')
this.messages.push(wewMessage)