resubcribe on reconnect

This commit is contained in:
Peter Maquiran
2022-01-31 14:44:22 +01:00
parent 210a5ecbf0
commit 5bf5d15d76
3 changed files with 37 additions and 1 deletions
@@ -54,6 +54,18 @@ export class WsChatMethodsService {
})()
/**
* @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.WsChatService.registerCallback({
type: 'reConnect',
funx: ()=>{
this.subscribeToRoom()
}
})
}
openRoom(roomId) {
@@ -116,11 +128,17 @@ export class WsChatMethodsService {
this.loadingWholeList = false
}
/**
* @description sort room list by last message date
*/
sortRoomList() {
this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse()
this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse()
}
/**
* @description subscribe all room
*/
subscribeToRoom() {
for (const id in this.dm) {