mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix
This commit is contained in:
@@ -112,10 +112,7 @@ export class RoomService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isSenderIsNotMe(ChatMessage)) {
|
this.addMessageDB(ChatMessage)
|
||||||
// this.addMessageDB(ChatMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.scrollDown()
|
this.scrollDown()
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -137,17 +134,34 @@ export class RoomService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addMessageDB(ChatMessage) {
|
async addMessageDB(ChatMessage) {
|
||||||
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
|
if (environment.chatOffline) {
|
||||||
if(!Array.isArray(messages)) {
|
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
|
||||||
messages = []
|
if(!Array.isArray(messages)) {
|
||||||
}
|
messages = []
|
||||||
|
}
|
||||||
|
|
||||||
delete ChatMessage.temporaryData
|
if(!ChatMessage._id && environment.chatOffline) {
|
||||||
messages.push(ChatMessage)
|
|
||||||
|
delete ChatMessage.temporaryData
|
||||||
|
messages.push(ChatMessage)
|
||||||
|
this.storage.set('chatmsg' + this.id, messages)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const find = messages.find((message)=> {
|
||||||
|
return message._id == ChatMessage._id
|
||||||
|
})
|
||||||
|
|
||||||
|
if(!find) {
|
||||||
|
delete ChatMessage.temporaryData
|
||||||
|
messages.push(ChatMessage)
|
||||||
|
this.storage.set('chatmsg' + this.id, messages)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
this.storage.set('chatmsg' + this.id, messages)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async receiveMessageDelete() {
|
async receiveMessageDelete() {
|
||||||
@@ -349,23 +363,22 @@ export class RoomService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// runs onces only
|
// runs onces only
|
||||||
async loadHistory({limit = 100, forceUpdate = false }) {
|
async loadHistory({limit = 50, forceUpdate = false }) {
|
||||||
|
|
||||||
if(forceUpdate == false) {
|
if(forceUpdate == false) {
|
||||||
if (this.hasLoadHistory) {
|
if (this.hasLoadHistory) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
await this.restoreMessageFromDB()
|
||||||
this.restoreMessageFromDB()
|
|
||||||
|
|
||||||
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
|
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
|
||||||
console.log('loadHistory', chatHistory)
|
console.log('loadHistory', chatHistory)
|
||||||
|
|
||||||
|
|
||||||
await chatHistory.result.messages.reverse().forEach( async (message) => {
|
await chatHistory.result.messages.reverse().forEach( async (message) => {
|
||||||
|
|
||||||
this.prepareMessage(message)
|
this.prepareMessage(message)
|
||||||
|
|
||||||
this.messages = this.sortService.sortDate(this.messages, '_updatedAt')
|
this.messages = this.sortService.sortDate(this.messages, '_updatedAt')
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user