mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
remove console logs
This commit is contained in:
@@ -31,7 +31,6 @@ import { ChatDebuggingPage } from 'src/app/shared/popover/chat-debugging/chat-de
|
|||||||
import { EventTrigger } from 'src/app/services/eventTrigger.service';
|
import { EventTrigger } from 'src/app/services/eventTrigger.service';
|
||||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
|
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
|
||||||
|
|
||||||
|
|
||||||
import { Plugins } from '@capacitor/core';
|
import { Plugins } from '@capacitor/core';
|
||||||
|
|
||||||
const { App } = Plugins;
|
const { App } = Plugins;
|
||||||
@@ -175,58 +174,6 @@ export class ChatPage implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.routeCheck()
|
this.routeCheck()
|
||||||
|
|
||||||
|
|
||||||
if (!this.platform.is('desktop')) {
|
|
||||||
App.addListener('appStateChange', ({ isActive }) => {
|
|
||||||
if (isActive) {
|
|
||||||
// The app is in the foreground.
|
|
||||||
console.log('App is in the foreground');
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
this.ChatSystemService.subscribeToRoom()
|
|
||||||
this.RochetChatConnectorService.setStatus('online')
|
|
||||||
},1000);
|
|
||||||
|
|
||||||
/* const webSocketURL = environment.apiWsChatUrl;
|
|
||||||
const ws = new WebSocket(webSocketURL);
|
|
||||||
|
|
||||||
ws.addEventListener('open', () => {
|
|
||||||
console.log('WebSocket connection opened');
|
|
||||||
});
|
|
||||||
|
|
||||||
ws.addEventListener('message', (event) => {
|
|
||||||
const data = JSON.parse(event.data);
|
|
||||||
// Handle incoming messages from the Rocket.Chat server.
|
|
||||||
console.log('Received message:', data);
|
|
||||||
});
|
|
||||||
|
|
||||||
ws.addEventListener('close', (event) => {
|
|
||||||
console.log('WebSocket connection closed', event);
|
|
||||||
// Optionally, attempt to reopen the connection when it's closed.
|
|
||||||
// You can implement a reconnect strategy here.
|
|
||||||
setTimeout(() => {
|
|
||||||
this.reopenWebSocketConnection();
|
|
||||||
}, 5000); // Reopen the connection after 5 seconds (adjust as needed).
|
|
||||||
});
|
|
||||||
|
|
||||||
this.RochetChatConnectorService.sendStreamNotifyRoom("26XgGhKghKN8fN6v8KvDfW9jrjhKhoAWhM", SessionStore.user.UserName, 'typing', true).catch((error) => console.error(error));
|
|
||||||
|
|
||||||
ws.addEventListener('error', (error) => {
|
|
||||||
console.error('WebSocket error:', error);
|
|
||||||
// Handle WebSocket errors here.
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* this.reloadComponent(true) */
|
|
||||||
} else {
|
|
||||||
// The app is in the background.
|
|
||||||
console.log('App is in the background');
|
|
||||||
// You can perform actions specific to the background state here.
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reopenWebSocketConnection() {
|
reopenWebSocketConnection() {
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ import { NetworkServiceService} from 'src/app/services/network-service.service';
|
|||||||
import { ViewedMessageService } from './viewed-message.service'
|
import { ViewedMessageService } from './viewed-message.service'
|
||||||
import { NotificationsService } from '../notifications.service';
|
import { NotificationsService } from '../notifications.service';
|
||||||
import { Subscribe } from '../subcribe';
|
import { Subscribe } from '../subcribe';
|
||||||
|
import { Plugins } from '@capacitor/core';
|
||||||
|
|
||||||
|
const { App } = Plugins;
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@@ -103,16 +107,37 @@ export class ChatSystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener('resume', function () {
|
if(SessionStore.user?.ChatData?.data) {
|
||||||
|
this.restoreRooms();
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('resume', () => {
|
||||||
this.RochetChatConnectorService.setStatus('online')
|
this.RochetChatConnectorService.setStatus('online')
|
||||||
if(this._dm?.length == 0 && this._group?.length == 0) {
|
if(this._dm?.length == 0 && this._group?.length == 0) {
|
||||||
this.getAllRooms();
|
this.getAllRooms();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!this.platform.is('desktop')) {
|
||||||
|
App.addListener('appStateChange', ({ isActive }) => {
|
||||||
|
if (isActive) {
|
||||||
|
// The app is in the foreground.
|
||||||
|
console.log('App is in the foreground');
|
||||||
|
|
||||||
if(SessionStore.user?.ChatData?.data) {
|
this.currentRoom?.loadHistory({forceUpdate: true})
|
||||||
this.restoreRooms();
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.subscribeToRoom()
|
||||||
|
this.RochetChatConnectorService.setStatus('online')
|
||||||
|
},1000);
|
||||||
|
|
||||||
|
/* this.reloadComponent(true) */
|
||||||
|
} else {
|
||||||
|
// The app is in the background.
|
||||||
|
console.log('App is in the background');
|
||||||
|
// You can perform actions specific to the background state here.
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ export class MessageService {
|
|||||||
|
|
||||||
|
|
||||||
functionTimer = null;
|
functionTimer = null;
|
||||||
|
functionTimer2 = null;
|
||||||
|
|
||||||
async sendRequestAttachment() {
|
async sendRequestAttachment() {
|
||||||
|
|
||||||
@@ -295,7 +296,11 @@ export class MessageService {
|
|||||||
return uploadSuccessfully
|
return uploadSuccessfully
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendToRocketChatAttemp = 0
|
||||||
|
|
||||||
async sendRequest(params) {
|
async sendRequest(params) {
|
||||||
|
this.sendToRocketChatAttemp++;
|
||||||
|
|
||||||
if(params?.attachments) {
|
if(params?.attachments) {
|
||||||
if(params?.attachments[0]?.image_url) {
|
if(params?.attachments[0]?.image_url) {
|
||||||
delete params?.attachments[0]?.image_url
|
delete params?.attachments[0]?.image_url
|
||||||
@@ -320,6 +325,7 @@ export class MessageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// console.log('online')
|
||||||
|
|
||||||
this.RochetChatConnectorService.send(params).then(
|
this.RochetChatConnectorService.send(params).then(
|
||||||
(ChatMessage: any) => {
|
(ChatMessage: any) => {
|
||||||
@@ -336,16 +342,16 @@ export class MessageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.functionTimer = setTimeout(() => {
|
this.functionTimer = setTimeout(() => {
|
||||||
|
//console.log('functionTimer')
|
||||||
|
|
||||||
this.RochetChatConnectorService.registerCallback({
|
this.RochetChatConnectorService.registerCallback({
|
||||||
type:'Onmessage',
|
type:'Onmessage',
|
||||||
key:'ping-pong-message',
|
key:'ping-pong-message',
|
||||||
funx:(message: any) => {
|
funx:(message: any) => {
|
||||||
|
|
||||||
|
// clearTimeout(this.functionTimer2);
|
||||||
if(message.msg == "ping") {
|
if(message.msg == "ping") {
|
||||||
if(this.sendAttempt >= 3) {
|
this.sendRequest(params)
|
||||||
this.manualRetry = true
|
|
||||||
} else {
|
|
||||||
this.send()
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,11 +359,24 @@ export class MessageService {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// this.functionTimer2 = setTimeout(() => {
|
||||||
|
// console.log('set to callback')
|
||||||
|
// this.RochetChatConnectorService.registerCallback({
|
||||||
|
// type: 'reConnect',
|
||||||
|
// funx: async ()=> {
|
||||||
|
// this.sendRequest(params)
|
||||||
|
|
||||||
|
// return true
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }, 4000)
|
||||||
|
|
||||||
this.RochetChatConnectorService.wsSend({message:{msg:"pong"}, loginRequired: false})
|
this.RochetChatConnectorService.wsSend({message:{msg:"pong"}, loginRequired: false})
|
||||||
|
|
||||||
}, 3000)
|
}, 5000)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// console.log('offline')
|
||||||
this.RochetChatConnectorService.registerCallback({
|
this.RochetChatConnectorService.registerCallback({
|
||||||
type: 'reConnect',
|
type: 'reConnect',
|
||||||
funx: async ()=> {
|
funx: async ()=> {
|
||||||
|
|||||||
@@ -23,15 +23,11 @@ export class RochetChatConnectorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
console.log('Check conetion 11')
|
|
||||||
console.log(this.ws.connected)
|
|
||||||
// dont connect if is already connected
|
// dont connect if is already connected
|
||||||
if(this.ws.connected == true) {
|
if(this.ws.connected == true) {
|
||||||
console.log('Check conetion 22')
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Check conetion 33')
|
|
||||||
this.ws.connect();
|
this.ws.connect();
|
||||||
|
|
||||||
const message = {
|
const message = {
|
||||||
@@ -759,11 +755,10 @@ export class RochetChatConnectorService {
|
|||||||
this.socket.onclose = this.ws.onclose;
|
this.socket.onclose = this.ws.onclose;
|
||||||
this.socket.onerror = this.ws.onerror;
|
this.socket.onerror = this.ws.onerror;
|
||||||
|
|
||||||
console.log(' === on open connection ===')
|
|
||||||
},
|
},
|
||||||
onopen: async ()=> {
|
onopen: async ()=> {
|
||||||
|
|
||||||
console.log('===socket on connection open===')
|
|
||||||
|
|
||||||
this.ws.connected = true
|
this.ws.connected = true
|
||||||
this.backgroundservice.online();
|
this.backgroundservice.online();
|
||||||
@@ -842,7 +837,7 @@ export class RochetChatConnectorService {
|
|||||||
onclose: async (event: any)=> {
|
onclose: async (event: any)=> {
|
||||||
this.ws.connected = false
|
this.ws.connected = false
|
||||||
this.isLogin = false
|
this.isLogin = false
|
||||||
console.error('===close socket connection===')
|
|
||||||
|
|
||||||
this.connect()
|
this.connect()
|
||||||
this.login()
|
this.login()
|
||||||
@@ -864,10 +859,10 @@ export class RochetChatConnectorService {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onerror: (event: any) => {
|
onerror: (event: any) => {
|
||||||
console.log(' ==== error ====')
|
|
||||||
},
|
},
|
||||||
disconnect:() => {
|
disconnect:() => {
|
||||||
console.log('==== desconnect ====')
|
|
||||||
if(this.socket) {
|
if(this.socket) {
|
||||||
this.socket.onopen = (event: any) => {}
|
this.socket.onopen = (event: any) => {}
|
||||||
this.socket.onmessage = (event: any) => {}
|
this.socket.onmessage = (event: any) => {}
|
||||||
|
|||||||
Reference in New Issue
Block a user