This commit is contained in:
Peter Maquiran
2022-03-04 14:50:13 +01:00
parent c112080917
commit 4dd7c83279
4 changed files with 50 additions and 6 deletions
@@ -32,7 +32,7 @@ export class ChatStorageService {
})
this.storage.set('chatmsg' + roomId, messages).then((value) => {
console.log('MSG SAVED ON STORAGE', value)
// console.log('MSG SAVED ON STORAGE', value)
});
})
@@ -66,7 +66,7 @@ export class ChatStorageService {
await this.storage.set('chatmsg' + roomId, messages)
} else {
console.log('failed to update', identificator, ':',ChatMessage)
// console.log('failed to update', identificator, ':',ChatMessage)
}
})
@@ -130,6 +130,7 @@ export class ChatStorageService {
delete ChatMessage.temporaryData
messages.push(ChatMessage)
console.log('no ID')
await this.storage.set('chatmsg' + roomId, messages)
// console.log('add to DB', ChatMessage)
@@ -165,6 +166,7 @@ export class ChatStorageService {
delete ChatMessage.temporaryData
messages.push(ChatMessage)
// console.log('add to DB')
} else {
const find = messages.find((message)=> {
@@ -174,6 +176,7 @@ export class ChatStorageService {
if(!find) {
delete ChatMessage.temporaryData
messages.push(ChatMessage)
// console.log('add to DB')
}
@@ -181,7 +184,7 @@ export class ChatStorageService {
}
})
console.log('add to DB')
await this.storage.set('chatmsg' + roomId, messages)
+12 -2
View File
@@ -142,7 +142,7 @@ export class MessageService {
this.WsChatService.registerCallback({
type: 'reConnect',
funx: async ()=> {
this.WsChatService.send(params).then(({message, requestId}) => {
let ChatMessage = message.result
this.messageSend = true
@@ -186,7 +186,6 @@ export class MessageService {
},
(error) => {
this.WsChatService.registerCallback({
type: 'reConnect',
funx: async ()=> {
@@ -239,8 +238,19 @@ export class MessageService {
reference = 'localReference'
}
const message = this.getChatObj()
// const viewed = [...new Set([...ChatMessage.viewed,...this.viewed])];
// const received = [...new Set([...ChatMessage.received,...this.received])];
// if(ChatMessage.msg.includes('***********')) {
// console.log('redefinedMessage')
// console.log(JSON.stringify(ChatMessage))
// console.log(JSON.stringify(message))
// console.log(JSON.stringify(Object.assign(message, ChatMessage)))
// }
ChatMessage = Object.assign(message, ChatMessage)
+27 -1
View File
@@ -273,6 +273,8 @@ export class RoomService {
temporaryData,
localReference
}
this.message= ''
const message: MessageService = await this.prepareMessage({message:offlineChatMessage, save: environment.chatOffline})
@@ -292,7 +294,7 @@ export class RoomService {
this.sortRoomList()
}
this.message= ''
}
@@ -570,6 +572,30 @@ export class RoomService {
}
/**
* @description find or create message
* @param message
* @param save
* @returns
*/
async prepareCreate({message}): Promise<MessageService> {
message = this.fix_updatedAt(message)
const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService)
wewMessage.setData(message)
wewMessage.loadHistory = this.hasLoadHistory
if(!message?._id && environment.chatOffline) {
this.messages.push(wewMessage)
return wewMessage
}
}
simplePrepareMessage(message) {
message = this.fix_updatedAt(message)
const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService)
@@ -54,6 +54,11 @@
<div class="d-flex justify-space-between">
<ion-label class="flex-0">{{msg.msg}} </ion-label>
<ion-label class="float-status-all float-status" >
{{ msg.messageSend }}
{{ msg.received.length }}
{{ msg.viewed.length }}
::{{ msg.sendAttempt }}::
<ion-icon *ngIf="msg.messageSend == false" src="assets/images/clock-regular.svg"></ion-icon>
<ion-icon *ngIf="msg.messageSend == true && msg.received.length == 0" src="assets/images/check-solid.svg"></ion-icon>