mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
merge
This commit is contained in:
@@ -52,7 +52,7 @@ export class RoomService {
|
||||
this.NativeNotificationService.askForPermission()
|
||||
}
|
||||
|
||||
setData({ customFields, id, name, t, lastMessage = new MessageService(), _updatedAt }) {
|
||||
setData({ customFields, id, name, t, lastMessage = new MessageService(this.storage), _updatedAt }) {
|
||||
this.customFields = customFields
|
||||
this.id = id
|
||||
this.name = name
|
||||
@@ -74,7 +74,7 @@ export class RoomService {
|
||||
console.log('recivemessage', ChatMessage)
|
||||
|
||||
/* this.ToastService._chatMessage({message:'Nova mensagem', sender:'Gilson'}) */
|
||||
const message = new MessageService()
|
||||
const message = new MessageService(this.storage)
|
||||
message.setData(ChatMessage)
|
||||
|
||||
this.lastMessage = message
|
||||
@@ -231,7 +231,7 @@ export class RoomService {
|
||||
|
||||
let mmessage = this.fix_updatedAt(msgChat)
|
||||
console.log('FROM DB WEB', mmessage)
|
||||
const wewMessage = new MessageService()
|
||||
const wewMessage = new MessageService(this.storage)
|
||||
wewMessage.setData(mmessage)
|
||||
this.messages.push(wewMessage)
|
||||
console.log('loadHistory 222', this.messages)
|
||||
@@ -250,8 +250,8 @@ export class RoomService {
|
||||
|
||||
getMsgFromDB() {
|
||||
|
||||
this.storage.get('chatmsg' + this.id).then((message) => {
|
||||
|
||||
/* this.storage.get('chatmsg' + this.id).then((message) => {
|
||||
console.log('ALL MESSAGE WEB', message)
|
||||
message.forEach(message => {
|
||||
|
||||
if (message.file) {
|
||||
@@ -265,12 +265,12 @@ export class RoomService {
|
||||
|
||||
let mmessage = this.fix_updatedAt(message)
|
||||
console.log('FROM DB WEB', mmessage)
|
||||
const wewMessage = new MessageService()
|
||||
const wewMessage = new MessageService(this.storage)
|
||||
wewMessage.setData(mmessage)
|
||||
this.messages.push(wewMessage)
|
||||
console.log('loadHistory 222', this.messages)
|
||||
});
|
||||
})
|
||||
}) */
|
||||
}
|
||||
|
||||
|
||||
@@ -280,44 +280,57 @@ export class RoomService {
|
||||
|
||||
if (this.hasLoadHistory) { return false }
|
||||
|
||||
/* this.WsChatService.loadHistory(this.id, limit).then((chatHistory:chatHistory) => {
|
||||
console.log('loadHistory', chatHistory)
|
||||
this.storage.get('chatmsg' + this.id).then((messages = [])=>{
|
||||
messages.forEach(message => {
|
||||
message = this.fix_updatedAt(message)
|
||||
const wewMessage = new MessageService(this.storage)
|
||||
wewMessage.setData(message)
|
||||
this.messages.push(wewMessage)
|
||||
});
|
||||
})
|
||||
|
||||
this.WsChatService.loadHistory(this.id, limit).then((chatHistory:chatHistory) => {
|
||||
console.log('loadHistory', chatHistory)
|
||||
|
||||
|
||||
let localMessages = []
|
||||
chatHistory.result.messages.reverse().forEach(message => {
|
||||
|
||||
message = this.fix_updatedAt(message)
|
||||
const wewMessage = new MessageService()
|
||||
const wewMessage = new MessageService(this.storage)
|
||||
wewMessage.setData(message)
|
||||
this.massages.push(wewMessage)
|
||||
localMessages.push(wewMessage)
|
||||
});
|
||||
|
||||
this.messages = localMessages
|
||||
|
||||
}) */
|
||||
|
||||
this.WsChatService.loadHistory(this.id, limit).then(async (chatHistory: chatHistory) => {
|
||||
|
||||
const mgsArray = chatHistory.result.messages.reverse();
|
||||
console.log(mgsArray);
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
await this.storage.remove('chatmsg' + this.id).then(() => {
|
||||
console.log('MSG REMOVE ON STORAGE')
|
||||
})
|
||||
await this.storage.set('chatmsg' + this.id, mgsArray).then((value) => {
|
||||
console.log('MSG SAVED ON STORAGE', value)
|
||||
this.getMsgFromDB()
|
||||
});
|
||||
} else {
|
||||
mgsArray.forEach((element) => {
|
||||
console.log('SQLITE WEBSOCKET', element)
|
||||
this.sqlservice.addChatMSG(element)
|
||||
})
|
||||
this.getMsgFromDBMobile()
|
||||
}
|
||||
this.storage.set('chatmsg' + this.id, chatHistory.result.messages.reverse())
|
||||
|
||||
|
||||
})
|
||||
|
||||
/* this.WsChatService.loadHistory(this.id, limit).then(async (chatHistory: chatHistory) => {
|
||||
|
||||
const mgsArray = chatHistory.result.messages.reverse();
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
await this.storage.remove('chatmsg' + this.id).then(() => {
|
||||
console.log('MSG REMOVE ON STORAGE')
|
||||
})
|
||||
await this.storage.set('chatmsg' + this.id, mgsArray).then((value) => {
|
||||
console.log('MSG SAVED ON STORAGE', value)
|
||||
this.getMsgFromDB()
|
||||
});
|
||||
} else {
|
||||
mgsArray.forEach((element) => {
|
||||
console.log('SQLITE WEBSOCKET', element)
|
||||
this.sqlservice.addChatMSG(element)
|
||||
})
|
||||
this.getMsgFromDBMobile()
|
||||
}
|
||||
|
||||
|
||||
}) */
|
||||
|
||||
setTimeout(() => {
|
||||
this.scrollDown()
|
||||
}, 50)
|
||||
|
||||
Reference in New Issue
Block a user