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.ts = ts
this.u = u || { name: this.usernameToDisplayName(SessionStore.user.UserName), username: SessionStore.user.UserName, _id: ""} this.u = u || { name: this.usernameToDisplayName(SessionStore.user.UserName), username: SessionStore.user.UserName, _id: ""}
this.t = t this.t = t
this._id = _id this._id = _id || ""
this._updatedAt = _updatedAt || new Date().getTime() this._updatedAt = _updatedAt || new Date().getTime()
this.file = file this.file = file
this.temporaryData = temporaryData this.temporaryData = temporaryData
+27 -1
View File
@@ -530,9 +530,9 @@ export class RoomService {
this.message= '' this.message= ''
this.messagesLocalReference.push(localReference)
const message: MessageService = await this.prepareCreate({message:offlineChatMessage, save: environment.chatOffline}) const message: MessageService = await this.prepareCreate({message:offlineChatMessage, save: environment.chatOffline})
this.messagesLocalReference.push(localReference)
await message.addMessageDB() await message.addMessageDB()
message.send() message.send()
@@ -822,8 +822,34 @@ export class RoomService {
wewMessage.setData(message) wewMessage.setData(message)
wewMessage.loadHistory = this.hasLoadHistory wewMessage.loadHistory = this.hasLoadHistory
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) this.messages.push(wewMessage)
return wewMessage return wewMessage
}
return wewMessage
} }
@@ -49,7 +49,7 @@
<div class="title"> <div class="title">
<ion-label>{{msg.u.name}}</ion-label> <ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{msg.duration}}</span> <span class="time">{{msg.duration}}</span>
<!-- {{msg._id}} --> {{msg._id}}
</div> </div>
<div class="d-flex justify-space-between"> <div class="d-flex justify-space-between">