remove duplicate

This commit is contained in:
Peter Maquiran
2022-07-22 17:15:32 +01:00
parent bc85eb6e1a
commit f0c8de79f2
3 changed files with 30 additions and 4 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ export class MessageService {
this.ts = ts
this.u = u || { name: this.usernameToDisplayName(SessionStore.user.UserName), username: SessionStore.user.UserName, _id: ""}
this.t = t
this._id = _id
this._id = _id || ""
this._updatedAt = _updatedAt || new Date().getTime()
this.file = file
this.temporaryData = temporaryData
+28 -2
View File
@@ -530,9 +530,9 @@ export class RoomService {
this.message= ''
this.messagesLocalReference.push(localReference)
const message: MessageService = await this.prepareCreate({message:offlineChatMessage, save: environment.chatOffline})
this.messagesLocalReference.push(localReference)
await message.addMessageDB()
message.send()
@@ -822,7 +822,33 @@ export class RoomService {
wewMessage.setData(message)
wewMessage.loadHistory = this.hasLoadHistory
this.messages.push(wewMessage)
let found;
if(wewMessage.localReference != null) {
found = this.messages.find((MessageService, index) => {
if ( MessageService.localReference == wewMessage.localReference ) {
return true
} else {
return false
}
})
} else {
found = this.messages.find((MessageService, index) => {
if ( MessageService._id == wewMessage._id) {
return true
} else {
return false
}
})
}
if (!found) {
this.messages.push(wewMessage)
return wewMessage
}
return wewMessage
}