fix load image

This commit is contained in:
Peter Maquiran
2022-01-20 15:33:55 +01:00
parent e86d9d8b35
commit 38fcf7e514
3 changed files with 38 additions and 18 deletions
+28 -15
View File
@@ -67,6 +67,16 @@ export class RoomService {
this.scrollDown()
}, 100)
// save to ionic storage
this.storage.get('chatmsg'+ this.id).then((messages: any) => {
const newListMessages = messages.push(ChatMessage)
this.storage.set('chatmsg'+ this.id, newListMessages).then((value) => {
console.log('MSG SAVED ON STORAGE', value)
});
})
}
)
}
@@ -80,25 +90,29 @@ export class RoomService {
if (this.hasLoadHistory) { return false }
// ionic store
this.storage.get('chatmsg'+ this.id).then((message) => {
message.forEach(message => {
console.log('FROM DB WEB', message)
message = this.fix_updatedAt(message)
const wewMessage = new MessageService()
wewMessage.setData(message)
this.massages.push(wewMessage)
console.log('loadHistory 222', this.massages)
});
})
// websocket
this.WsChatService.loadHistory(this.id, limit).then(async (chatHistory: chatHistory) => {
//await this.transformData(chatHistory.result.messages.reverse());
/* console.log('loadHistory 111', chatHistory.result.messages.reverse())
this.mgsArray = chatHistory.result.messages.reverse();
await this.storage.set('chatmsg', this.mgsArray).then((value) => {
//console.log('loadHistory 111', chatHistory.result.messages.reverse())
const mgsArray = chatHistory.result.messages.reverse();
await this.storage.set('chatmsg'+this.id, mgsArray).then((value) => {
console.log('MSG SAVED ON STORAGE', value)
}); */
});
/* await this.storage.get('chatmsg').then((message) => {
message.forEach(message => {
console.log('FROM DB WEB', message)
message = this.fix_updatedAt(message)
const wewMessage = new MessageService()
wewMessage.setData(message)
this.massages.push(wewMessage)
console.log('loadHistory 222', this.massages)
});
}) */
chatHistory.result.messages.reverse().forEach(message => {
message = this.fix_updatedAt(message)
@@ -152,7 +166,6 @@ export class RoomService {
ts: element.ts,
u: element.u,
_updatedAt: element._updatedAt ,
}
this.mgsArray.push(chatmsg);