This commit is contained in:
Peter Maquiran
2022-09-26 18:15:41 +01:00
parent bf60b355fe
commit de3a4583dc
5 changed files with 156 additions and 61 deletions
+40 -3
View File
@@ -57,6 +57,15 @@ export class RoomService {
chatOpen = false
messageUnread = false
status = {
receive: {
message: false,
typing: false,
readMessage: false,
deleteMessage: false
}
}
scrollDown = () => { }
/**
@@ -128,6 +137,17 @@ export class RoomService {
}
})
this.WsChatService.registerCallback({
type: 'Offline',
funx: () => {
/**
* @description when the phone is in the background for a long time it could disconnects from the socket then the socket reconnects automatically,
* when the connection is lost the subscribe is also lost, so we have to subscribe again when reconnection is establish.
*/
this.resetStatus();
}
})
}
/**
@@ -150,6 +170,18 @@ export class RoomService {
}
}
resetStatus() {
this.status = {
receive: {
message: false,
typing: false,
readMessage: false,
deleteMessage: false
}
}
}
setData({members, u, customFields = {}, id, name, t, lastMessage = new MessageService(this.storage, this.NfService, this.WsChatService, this.ChatStorageService, this.ChatMethodsService, this.AESEncrypt, this.AttachmentsService, this.NetworkServiceService), _updatedAt }) {
this.customFields = customFields
this.id = id
@@ -454,9 +486,14 @@ export class RoomService {
//Get previous last message from room
const previousLastMessage = this.messages.slice(-1)[0];
this.lastMessage = previousLastMessage;
this.calDateDuration(previousLastMessage._updatedAt)
this.sortRoomList()
if(previousLastMessage) {
this.lastMessage = previousLastMessage;
console.log("last message"+ previousLastMessage)
this.calDateDuration(previousLastMessage._updatedAt)
this.sortRoomList()
}
return true