mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
bug fix in chat view
This commit is contained in:
@@ -52,8 +52,9 @@ export class RoomService {
|
||||
|
||||
receiveMessage() {
|
||||
|
||||
this.WsChatService.receiveLiveMessageFromRoom(
|
||||
this.WsChatService.upateRoomEvents(
|
||||
this.id,
|
||||
"stream-room-messages",
|
||||
(ChatMessage) => {
|
||||
ChatMessage = ChatMessage.fields.args[0]
|
||||
ChatMessage = this.fix_updatedAt(ChatMessage)
|
||||
@@ -63,7 +64,7 @@ export class RoomService {
|
||||
const message = new MessageService()
|
||||
message.setData(ChatMessage)
|
||||
|
||||
this.lastMessage.msg = message.msg
|
||||
this.lastMessage = message
|
||||
if (message.t == 'r') { this.name = message.msg }
|
||||
this.calDateDuration(ChatMessage._updatedAt)
|
||||
this.massages.push(message)
|
||||
@@ -84,6 +85,37 @@ export class RoomService {
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
this.WsChatService.registerCallback
|
||||
}
|
||||
|
||||
async receiveMessageDelete() {
|
||||
|
||||
this.WsChatService.upateRoomEvents(
|
||||
this.id,
|
||||
"stream-notify-room",
|
||||
async (ChatMessage) => {
|
||||
console.log(ChatMessage.fields.args[0]._id);
|
||||
const messageId = ChatMessage.fields.args[0]._id;
|
||||
this.massages.forEach((message, index)=>{
|
||||
if(message._id == messageId){
|
||||
this.massages.splice(index, 1)
|
||||
this.storage.set('chatmsg' + this.id, this.massages).then((value) => {
|
||||
//console.log('MSG DELETE ON STORAGE', value)
|
||||
});
|
||||
|
||||
//Get previous last message from room
|
||||
const previousLastMessage = this.massages.slice(-1)[0];
|
||||
|
||||
this.lastMessage = previousLastMessage;
|
||||
this.calDateDuration(previousLastMessage._updatedAt)
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
)
|
||||
this.WsChatService.registerCallback
|
||||
}
|
||||
|
||||
send(msg) {
|
||||
@@ -148,7 +180,7 @@ export class RoomService {
|
||||
if (message.file) {
|
||||
if (message.file.guid) {
|
||||
this.storage.get(message.file.guid).then((image) => {
|
||||
console.log('IMAGE FROM STORAGE', image)
|
||||
//console.log('IMAGE FROM STORAGE', image)
|
||||
message.file.image_url = image
|
||||
});
|
||||
}
|
||||
@@ -188,6 +220,8 @@ export class RoomService {
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user