diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 76d77f1d0..a508f72d2 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -133,11 +133,6 @@ export class AuthService { localStorage.setItem('userChat', JSON.stringify(responseChat)); this.storageService.store(AuthConnstants.AUTH, responseChat); - - - if(window['setChatHeader']){ - window['setChatHeader']() - } return true; } diff --git a/src/app/services/chat.service.ts b/src/app/services/chat.service.ts index 666decc63..bb772b459 100644 --- a/src/app/services/chat.service.ts +++ b/src/app/services/chat.service.ts @@ -13,7 +13,7 @@ import { Observable, Subject } from "rxjs/Rx"; providedIn: 'root' }) export class ChatService { - headers: HttpHeaders; + _headers: HttpHeaders; options:any; options1:any; X_User_Id:any; @@ -31,19 +31,23 @@ export class ChatService { private storage: Storage, private storageService:StorageService, ) - { - this.setHeader() - window['setChatHeader'] = this.setHeader + {} + + + get headers() { + this.loggedUserChat = this.authService.ValidatedUserChat; + this._headers = new HttpHeaders(); + this._headers = this._headers.set('X-User-Id', this.loggedUserChat['data'].userId); + this._headers = this._headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken); + this.options = { + headers: this._headers, + }; + + return this._headers } setHeader = () => { - this.loggedUserChat = this.authService.ValidatedUserChat; - this.headers = new HttpHeaders(); - this.headers = this.headers.set('X-User-Id', this.loggedUserChat['data'].userId); - this.headers = this.headers.set('X-Auth-Token', this.loggedUserChat['data'].authToken); - this.options = { - headers: this.headers, - }; + } getDocumentDetails(url:string){ diff --git a/src/app/services/chat/ws-chat.service.ts b/src/app/services/chat/ws-chat.service.ts index 586035907..a2c252654 100644 --- a/src/app/services/chat/ws-chat.service.ts +++ b/src/app/services/chat/ws-chat.service.ts @@ -602,11 +602,11 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) { for (const [key, item] of Object.entries(this.wsMsgQueue)) { if(item.loginRequired == true && this.isLogin == true) { - // console.log('run msgQueue ',index) + console.log('run msgQueue ', key) this.ws.send(item); delete this.wsMsgQueue[key] } else if(item.loginRequired == false) { - // console.log('run msgQueue ',index) + console.log('run msgQueue ', key) this.ws.send(item); delete this.wsMsgQueue[key] } @@ -616,6 +616,8 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) { if (this.ws.connected == false || loginRequired == true && this.isLogin == false) { // save data to send when back online // console.log('save msgQueue this.ws.connected == false || loginRequired == true && this.isLogin == false',this.ws.connected, loginRequired, this.isLogin) + console.log('save msgQueue', requestId) + this.wsMsgQueue[requestId] = {message, requestId, loginRequired} } else { let messageStr = JSON.stringify(message)