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()
|
||||
|
||||
}
|
||||
@@ -137,17 +134,34 @@ export class RoomService {
|
||||
}
|
||||
|
||||
|
||||
addMessageDB(ChatMessage) {
|
||||
async addMessageDB(ChatMessage) {
|
||||
if (environment.chatOffline) {
|
||||
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
|
||||
if(!Array.isArray(messages)) {
|
||||
messages = []
|
||||
}
|
||||
|
||||
if(!ChatMessage._id && environment.chatOffline) {
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async receiveMessageDelete() {
|
||||
@@ -349,23 +363,22 @@ export class RoomService {
|
||||
}
|
||||
|
||||
// runs onces only
|
||||
async loadHistory({limit = 100, forceUpdate = false }) {
|
||||
async loadHistory({limit = 50, forceUpdate = false }) {
|
||||
|
||||
if(forceUpdate == false) {
|
||||
if (this.hasLoadHistory) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
this.restoreMessageFromDB()
|
||||
await this.restoreMessageFromDB()
|
||||
|
||||
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
|
||||
console.log('loadHistory', chatHistory)
|
||||
|
||||
|
||||
await chatHistory.result.messages.reverse().forEach( async (message) => {
|
||||
|
||||
this.prepareMessage(message)
|
||||
|
||||
this.messages = this.sortService.sortDate(this.messages, '_updatedAt')
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user