mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
chat
This commit is contained in:
@@ -32,7 +32,7 @@ export class ChatStorageService {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.storage.set('chatmsg' + roomId, messages).then((value) => {
|
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)
|
await this.storage.set('chatmsg' + roomId, messages)
|
||||||
} else {
|
} 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
|
delete ChatMessage.temporaryData
|
||||||
messages.push(ChatMessage)
|
messages.push(ChatMessage)
|
||||||
|
console.log('no ID')
|
||||||
|
|
||||||
await this.storage.set('chatmsg' + roomId, messages)
|
await this.storage.set('chatmsg' + roomId, messages)
|
||||||
// console.log('add to DB', ChatMessage)
|
// console.log('add to DB', ChatMessage)
|
||||||
@@ -165,6 +166,7 @@ export class ChatStorageService {
|
|||||||
|
|
||||||
delete ChatMessage.temporaryData
|
delete ChatMessage.temporaryData
|
||||||
messages.push(ChatMessage)
|
messages.push(ChatMessage)
|
||||||
|
// console.log('add to DB')
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const find = messages.find((message)=> {
|
const find = messages.find((message)=> {
|
||||||
@@ -174,6 +176,7 @@ export class ChatStorageService {
|
|||||||
if(!find) {
|
if(!find) {
|
||||||
delete ChatMessage.temporaryData
|
delete ChatMessage.temporaryData
|
||||||
messages.push(ChatMessage)
|
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)
|
await this.storage.set('chatmsg' + roomId, messages)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,6 @@ export class MessageService {
|
|||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
|
||||||
|
|
||||||
this.WsChatService.registerCallback({
|
this.WsChatService.registerCallback({
|
||||||
type: 'reConnect',
|
type: 'reConnect',
|
||||||
funx: async ()=> {
|
funx: async ()=> {
|
||||||
@@ -239,8 +238,19 @@ export class MessageService {
|
|||||||
reference = 'localReference'
|
reference = 'localReference'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const message = this.getChatObj()
|
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)
|
ChatMessage = Object.assign(message, ChatMessage)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -274,6 +274,8 @@ export class RoomService {
|
|||||||
localReference
|
localReference
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.message= ''
|
||||||
|
|
||||||
const message: MessageService = await this.prepareMessage({message:offlineChatMessage, save: environment.chatOffline})
|
const message: MessageService = await this.prepareMessage({message:offlineChatMessage, save: environment.chatOffline})
|
||||||
|
|
||||||
this.messagesLocalReference.push(localReference)
|
this.messagesLocalReference.push(localReference)
|
||||||
@@ -292,7 +294,7 @@ export class RoomService {
|
|||||||
this.sortRoomList()
|
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) {
|
simplePrepareMessage(message) {
|
||||||
message = this.fix_updatedAt(message)
|
message = this.fix_updatedAt(message)
|
||||||
const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService)
|
const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService)
|
||||||
|
|||||||
@@ -55,6 +55,11 @@
|
|||||||
<ion-label class="flex-0">{{msg.msg}} </ion-label>
|
<ion-label class="flex-0">{{msg.msg}} </ion-label>
|
||||||
<ion-label class="float-status-all float-status" >
|
<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 == 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>
|
<ion-icon *ngIf="msg.messageSend == true && msg.received.length == 0" src="assets/images/check-solid.svg"></ion-icon>
|
||||||
<ion-icon *ngIf="msg.messageSend && msg.received.length >= 1 && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon>
|
<ion-icon *ngIf="msg.messageSend && msg.received.length >= 1 && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon>
|
||||||
|
|||||||
Reference in New Issue
Block a user