This commit is contained in:
Peter Maquiran
2022-02-10 21:50:15 +01:00
parent 54020c2247
commit 4b66eb6713
4 changed files with 28 additions and 21 deletions
+1 -1
View File
@@ -143,7 +143,7 @@ export class MessageService {
let ChatMessage = message.result
if (environment.chatOffline) {
this.redefinedMessage(ChatMessage)
// this.redefinedMessage(ChatMessage)
this.offline = false
}
+4 -6
View File
@@ -80,6 +80,8 @@ export class RoomService {
this._updatedAt = _updatedAt
this.calDateDuration()
this.restoreMessageFromDB()
}
@@ -94,7 +96,6 @@ export class RoomService {
"stream-room-messages",
(_ChatMessage) => {
console.log('recivemessage', _ChatMessage)
alert('receive and send to view')
let ChatMessage = _ChatMessage.fields.args[0]
ChatMessage = this.fix_updatedAt(ChatMessage)
@@ -270,7 +271,7 @@ export class RoomService {
*/
async send({file = null, attachments = null, temporaryData = {}}) {
const localReference = uuidv4() + 'peter'
const localReference = uuidv4()
let offlineChatMessage = {
rid: this.id,
@@ -403,7 +404,7 @@ export class RoomService {
if(wewMessage.offline == false) {
this.prepareMessage(ChatMessage)
} else {
if(environment.chatOffline) alert('create offline')
const offlineMessage = this.prepareMessage(ChatMessage)
this.messagesLocalReference.push(offlineMessage.localReference)
@@ -432,7 +433,6 @@ export class RoomService {
return false
}
}
await this.restoreMessageFromDB()
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
console.log('loadHistory', chatHistory)
@@ -464,7 +464,6 @@ export class RoomService {
wewMessage.loadHistory = this.hasLoadHistory
if(!message._id && environment.chatOffline && save) {
if(this.hasLoadHistory && environment.chatOffline) alert('create offline')
this.messages.push(wewMessage)
return wewMessage
@@ -480,7 +479,6 @@ export class RoomService {
})
if (save && !found) {
if(this.hasLoadHistory && environment.chatOffline) alert('not found')
this.messages.push(wewMessage)
}
@@ -193,11 +193,6 @@ export class WsChatMethodsService {
console.log('rooms', rooms)
this.dm = {}
this.group = {}
this._dm = []
this._group = []
await rooms.result.update.forEach( async (roomData: room) => {
await this.prepareRoom(roomData);
});
@@ -273,14 +268,17 @@ export class WsChatMethodsService {
room = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService)
room.setData({
const setData = {
customFields: roomData.customFields,
id: this.getRoomId(roomData),
name: this.getRoomName(roomData),
t: roomData.t,
lastMessage: this.getRoomLastMessage(roomData),
_updatedAt: new Date(roomData._updatedAt['$date'])
})
}
room.setData(setData)
room.receiveMessage()
room.getAllUsers = this.getUsers
@@ -290,13 +288,24 @@ export class WsChatMethodsService {
let roomId = this.getRoomId(roomData)
if(this.isIndividual(roomData)) {
this.dm[roomId] = room
this._dm.push(room)
this.dmCount++
if(!this.dm[roomId]) {
this.dm[roomId] = room
this._dm.push(room)
this.dmCount++
} else {
this.dm[roomId].setData(setData)
}
} else {
this.group[roomId] = room
this._group.push(room)
this.groupCount++
if(this.group[roomId]) {
this.group[roomId] = room
this._group.push(room)
this.groupCount++
} else {
this.group[roomId].setData(setData)
}
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ export const environment = {
domain: 'gabinetedigital.local', //gabinetedigital.local
defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto paulo.pinto@gabinetedigital.local
defaultuserpwd: 'tabteste@006', //tabteste@006,
chatOffline: false
chatOffline: true
};
/*