diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a40acec20..c87eb6035 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -80,19 +80,21 @@ export class AppComponent { try { this.sqliteservice.databaseConn(); } catch (error) { - // console.log("Error creating local database: ", error) + console.error("Error creating local database: ", error) } } - this.storageservice.get('networkCheckStore').then((network) => { + /* this.storageservice.get('networkCheckStore').then((network) => { if(network === 'online') { - // console.log('Network app componente check', network) + console.log('Network app componente check', network) this.backgroundservice.online() } else { - // console.log('Network app componente check', network) + console.log('Network app componente check', network) this.backgroundservice.offline(); } - }) + }).catch((error) => { + console.error('storage initialize: ',error) + }) */ }); } diff --git a/src/app/modals/chat-options-features/chat-options-features.page.ts b/src/app/modals/chat-options-features/chat-options-features.page.ts index 9f2bfb92d..3ebc82def 100644 --- a/src/app/modals/chat-options-features/chat-options-features.page.ts +++ b/src/app/modals/chat-options-features/chat-options-features.page.ts @@ -98,7 +98,12 @@ export class ChatOptionsFeaturesPage implements OnInit { const file = this.fileLoaderService.getFirstFile(input) - const imageData = await this.fileToBase64Service.convert(file) + let imageData; + try { + imageData = await this.fileToBase64Service.convert(file) + } catch (error) { + console.error('load picture chat',error) + } this.capturedImage = imageData; this.capturedImageTitle = file.name; diff --git a/src/app/modals/profile/profile.page.ts b/src/app/modals/profile/profile.page.ts index 0de056f9f..afe210711 100644 --- a/src/app/modals/profile/profile.page.ts +++ b/src/app/modals/profile/profile.page.ts @@ -116,6 +116,8 @@ export class ProfilePage implements OnInit { this.DataArray.push(notificationObject) }); this.notificationdata = this.DataArray + }).catch((error) => { + console.error('storage getnotification: ',error) }) /* await new Promise(resolve => setTimeout(resolve, 1000)); await this.getNotificationData(); */ @@ -193,7 +195,9 @@ export class ProfilePage implements OnInit { this.storageservice.store("Notifications", JSON.stringify(this.notificationdata)).then(() => { this.storageservice.get("Notifications").then((value) => { - }); + }).catch((error) => { + console.error('storage delete notification: ',error) + }) }); } diff --git a/src/app/modals/set-room-owner/set-room-owner.page.ts b/src/app/modals/set-room-owner/set-room-owner.page.ts index 40a0656d6..9c2632ca8 100644 --- a/src/app/modals/set-room-owner/set-room-owner.page.ts +++ b/src/app/modals/set-room-owner/set-room-owner.page.ts @@ -55,7 +55,12 @@ export class SetRoomOwnerPage implements OnInit { async setRoomOwner(user:any){ - let res:any = await this.ChatSystemService.addRoomOwner(this.roomId, user._id); + let res:any; + try { + res = await this.ChatSystemService.addRoomOwner(this.roomId, user._id) + } catch (error) { + console.error(error) + } if(res.error){ diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index bf7ad1f2d..75a6abc03 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -531,6 +531,7 @@ export class AgendaPage implements OnInit { this.showTimeline = true; }).catch((error) => { + console.error(error) this.getFromDB(); }).finally(() => { this.showLoader = false; @@ -589,6 +590,7 @@ export class AgendaPage implements OnInit { }).catch((error) => { + console.error(error) this.getFromDB() }) .finally(() => { @@ -622,6 +624,7 @@ export class AgendaPage implements OnInit { this.showTimeline = true; }).catch((error) => { + console.error(error) this.getFromDB(); }).finally(() => { this.showLoader = false; @@ -646,6 +649,7 @@ export class AgendaPage implements OnInit { this.showTimeline = true; }).catch((error) => { + console.error(error) this.getFromDB() }).finally(() => { this.showLoader = false; @@ -686,6 +690,7 @@ export class AgendaPage implements OnInit { }).catch((error) => { + console.error(error) this.getFromDB() }).finally(() => { counter++; @@ -757,6 +762,7 @@ export class AgendaPage implements OnInit { }).catch((error) => { + console.error(error) this.getFromDB() }).finally(() => { this.showLoader = false; @@ -794,6 +800,7 @@ export class AgendaPage implements OnInit { }).catch((error) => { + console.error(error) this.getFromDB() }).finally(() => { counter++; @@ -840,6 +847,7 @@ export class AgendaPage implements OnInit { } }).catch((error) => { + console.error(error) this.getFromDB() }) .finally(() => { @@ -995,7 +1003,9 @@ export class AgendaPage implements OnInit { }) } - }) + }).catch ((error) => { + console.error(error); + }); } diff --git a/src/app/pages/agenda/view-event/view-event.page.ts b/src/app/pages/agenda/view-event/view-event.page.ts index 5901c40a0..1f61df9ee 100644 --- a/src/app/pages/agenda/view-event/view-event.page.ts +++ b/src/app/pages/agenda/view-event/view-event.page.ts @@ -148,7 +148,9 @@ export class ViewEventPage implements OnInit { }) } - }) + }).catch ((error) => { + console.error(error); + }); } diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts index c2ddd9b0a..2e0556a02 100644 --- a/src/app/pages/chat/chat.page.ts +++ b/src/app/pages/chat/chat.page.ts @@ -403,10 +403,14 @@ export class ChatPage implements OnInit { // // + }).catch((error) => { + console.error('storage getdirectmessagedb: ',error) }) this.storageservice.get('chatusers').then((users) => { this.dmUsers = users.filter(data => data.username != SessionStore.user.UserName); + }).catch((error) => { + console.error('storage getchatusers: ',error) }) } else { this.sqlservice.getAllChatRoom().then((rooms: any) => { @@ -557,10 +561,14 @@ export class ChatPage implements OnInit { // + }).catch((error) => { + console.error('storage getGrup Romm db: ',error) }) this.storageservice.get('chatusers').then((users) => { this.dmUsers = users.filter(data => data.username != SessionStore.user.UserName); + }).catch((error) => { + console.error('storage getgrupDb: ',error) }) } else { this.sqlservice.getAllChatRoom().then((rooms: any) => { @@ -662,7 +670,9 @@ export class ChatPage implements OnInit { else { //Check if modal is opened if (this.segment == "Grupos" && this.showGroupMessages != true) { - await new Promise(resolve => setTimeout(resolve, 1000)); + await new Promise(resolve => setTimeout(resolve, 1000)).catch ((error) => { + console.error(error); + }); //await this.getGroups(); } } diff --git a/src/app/pages/chat/group-messages/group-messages.page.ts b/src/app/pages/chat/group-messages/group-messages.page.ts index 73c84fce4..573cdb045 100644 --- a/src/app/pages/chat/group-messages/group-messages.page.ts +++ b/src/app/pages/chat/group-messages/group-messages.page.ts @@ -733,7 +733,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") { - const encodedData = btoa(JSON.stringify(await this.getBase64(file))); + const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => { + console.error(error); + }))); const blob = this.base64toBlob(encodedData, file.type) const formData = new FormData(); @@ -977,7 +979,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy { } else { //Check if modal is opened if (document.querySelector('.isGroupChatOpened')) { - await new Promise(resolve => setTimeout(resolve, 5000)); + await new Promise(resolve => setTimeout(resolve, 5000)).catch ((error) => { + console.error(error); + }); await this.serverLongPull(); } diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 37f7f5bc9..fb0689084 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -154,6 +154,8 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { // this.chatService.refreshtoken(); this.ChatSystemService.getUserOfRoom(this.roomId).then((value) => { + }).catch((error) => { + console.error(error) }) this.getChatMembers(); @@ -747,7 +749,9 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") { - const encodedData = btoa(JSON.stringify(await this.getBase64(file))); + const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => { + console.error(error); + }))); const blob = this.base64toBlob(encodedData, file.type) diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts index d2fa65e96..cd87cd29c 100644 --- a/src/app/pages/events/events.page.ts +++ b/src/app/pages/events/events.page.ts @@ -195,7 +195,9 @@ export class EventsPage implements OnInit { if(this.loggeduser.OwnerCalendars.length >= 1) { - let onwEvent:any = await this.eventService.getAllOwnEvents(start, end) + let onwEvent:any = await this.eventService.getAllOwnEvents(start, end).catch((error) => { + console.error(error) + }) this.listToPresent = onwEvent; this.totalEvent = onwEvent.length; this.showLoader = false; diff --git a/src/app/pages/publications/new-publication/convertBlobToBase64.worker.js b/src/app/pages/publications/new-publication/convertBlobToBase64.worker.js index 62fc746e8..1d81ad388 100644 --- a/src/app/pages/publications/new-publication/convertBlobToBase64.worker.js +++ b/src/app/pages/publications/new-publication/convertBlobToBase64.worker.js @@ -5,7 +5,9 @@ convertBlobToBase64 = (blob) => new Promise((resolve, reject) => { resolve(reader.result); }; reader.readAsDataURL(blob); -}); +}).catch ((error) => { + console.error(error); +});; onmessage = async function(oEvent) { const result = await convertBlobToBase64(oEvent.data); diff --git a/src/app/pages/publications/new-publication/new-publication.page.ts b/src/app/pages/publications/new-publication/new-publication.page.ts index 25a9f2766..e08e53da1 100644 --- a/src/app/pages/publications/new-publication/new-publication.page.ts +++ b/src/app/pages/publications/new-publication/new-publication.page.ts @@ -142,6 +142,8 @@ export class NewPublicationPage implements OnInit { resolve(reader.result); }; reader.readAsDataURL(blob); + }).catch ((error) => { + console.error(error); }); diff --git a/src/app/services/alert.service.ts b/src/app/services/alert.service.ts index 819ca1c63..e3f6895fe 100644 --- a/src/app/services/alert.service.ts +++ b/src/app/services/alert.service.ts @@ -60,7 +60,7 @@ export class AlertService { this.ChatSystemService.deleteMessage(msgId).then(() => { room.deleteMessage(msgId) - }) + }).catch((error) => console.error(error)) //this.ChatSystemService.subscribeToRoomUpdate(room._id, room); //loader.remove(); } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 22ab1b377..f01eca89c 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -129,8 +129,8 @@ export class AuthService { // alert('wsLogin') - }).catch((message) => { - // alert('ws login failed') + }).catch((error) => { + console.error(error) }) @@ -150,7 +150,7 @@ export class AuthService { return true } catch(e) { - + console.error('BeforesendAtachment', e) return false } @@ -167,7 +167,7 @@ export class AuthService { return true } catch(e) { - + console.error('BeforesendAtachment', e) return false } } @@ -231,6 +231,8 @@ export class AuthService { getUserData() { this.storageService.get(AuthConnstants.AUTH).then(res=>{ this.userData$.next(res); + }).catch((error) => { + console.error('storage getuserdata',error) }); } diff --git a/src/app/services/chat.service.ts b/src/app/services/chat.service.ts index a9528172c..3baea940c 100644 --- a/src/app/services/chat.service.ts +++ b/src/app/services/chat.service.ts @@ -326,7 +326,9 @@ export class ChatService { //showMessage(response.statusText); this.getRoomMessages(roomId) // Reconnect in one second - await new Promise(resolve => setTimeout(resolve, 1000)); + await new Promise(resolve => setTimeout(resolve, 1000)).catch ((error) => { + console.error(error); + }); await this.subscribe(roomId); } else { // Got message diff --git a/src/app/services/chat/chat-system.service.ts b/src/app/services/chat/chat-system.service.ts index 0033dc89c..34e4b8e3e 100644 --- a/src/app/services/chat/chat-system.service.ts +++ b/src/app/services/chat/chat-system.service.ts @@ -183,7 +183,12 @@ export class ChatSystemService { async getAllRooms () { this.loadingWholeList = true - const rooms = await this.RochetChatConnectorService.getRooms(); + var rooms; + try { + rooms = await this.RochetChatConnectorService.getRooms(); + } catch (error) { + console.error('chatgetrooms',error) + } try { await this.storage.remove('Rooms'); } catch(e) {} diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 0dbce8010..17d15b0c7 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -166,7 +166,11 @@ export class MessageService { let uploadSuccessfully = false if(this.hasSendAttachment == false) { - uploadSuccessfully = await this.NfService.beforeSendAttachment(this) + try { + uploadSuccessfully = await this.NfService.beforeSendAttachment(this) + } catch (error) { + console.error('beforeSendAttachment uploadSuccessfully',error) + } this.UploadAttachmentsTemp++ } @@ -186,13 +190,17 @@ export class MessageService { this.RochetChatConnectorService.registerCallback({ type: 'reConnect', funx: async ()=> { - this.send() + this.send().catch((error) =>{ + console.error(error) + }) return true } }) } else if(uploadSuccessfully == false && this.UploadAttachmentsTemp == 1) { - this.send() + this.send().catch((error) =>{ + console.error(error) + }) } else if(uploadSuccessfully == false) { @@ -225,7 +233,9 @@ export class MessageService { this.messageSend = true this.redefinedMessage(ChatMessage) } - ) + ).catch((error) => { + console.error(error) + }) } else { // console.log("reconnect") @@ -233,7 +243,9 @@ export class MessageService { type: 'reConnect', funx: async ()=> { - this.send() + this.send().catch((error) =>{ + console.error(error) + }) return true } }) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index b424fa03b..5c63f35d1 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -630,7 +630,7 @@ export class RoomService { } if(lastIsTyping != this.isTyping) { - this.RochetChatConnectorService.sendStreamNotifyRoom(this.id, SessionStore.user.UserName, 'typing', this.isTyping) + this.RochetChatConnectorService.sendStreamNotifyRoom(this.id, SessionStore.user.UserName, 'typing', this.isTyping).catch((error) => console.error(error)); } @@ -639,7 +639,7 @@ export class RoomService { } sendFalseTypingReadMessage(method,param: object) { - this.RochetChatConnectorService.sendStreamNotifyRoom(this.id, SessionStore.user.UserName, 'typing', {method:method, params: param} as falseTypingMethod) + this.RochetChatConnectorService.sendStreamNotifyRoom(this.id, SessionStore.user.UserName, 'typing', {method:method, params: param} as falseTypingMethod).catch((error) => console.error(error)) this.setTypingOff() } @@ -651,7 +651,7 @@ export class RoomService { if(this.isTyping == true) { this.isTyping = false - this.RochetChatConnectorService.sendStreamNotifyRoom(this.id, SessionStore.user.UserName, 'typing', this.isTyping) + this.RochetChatConnectorService.sendStreamNotifyRoom(this.id, SessionStore.user.UserName, 'typing', this.isTyping).catch((error) => console.error(error)) } } @@ -675,7 +675,7 @@ export class RoomService { leave(rid?) { - this.RochetChatConnectorService.leaveRoom(this.id) + this.RochetChatConnectorService.leaveRoom(this.id).catch((error) => console.error(error)) } isJson(str) { @@ -1003,7 +1003,9 @@ export class RoomService { } sendReadMessage() { - this.RochetChatConnectorService.readMessage(this.id) + this.RochetChatConnectorService.readMessage(this.id).catch((error) =>{ + console.error(error) + }) this.sendFalseTypingReadMessage('viewMessage', {}) this.messageUnread = false } diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index 4c119b0b9..90b89c371 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -48,8 +48,8 @@ export class NotificationsService { this.storageService.get("Notifications").then((value) => { - }).catch(()=>{ - + }).catch((error)=>{ + console.error('storage getnotification',error) }).catch(() => { this.storageService.store("Notifications", []) @@ -122,8 +122,12 @@ export class NotificationsService { }, (error) => { //console.log(error) }) - }); + }).catch((error) => { + console.error('storage authorization', error) + });; + }).catch((error) => { + console.error('storage getAndPostToken', error) }); } ); diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index cd63b2953..7384b96a6 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -533,7 +533,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe this.getRoomInfo(); this.closeAllDesktopComponents.emit(); this.showEmptyContainer.emit(); - this.ChatSystemService.hidingRoom(this.roomId); + this.ChatSystemService.hidingRoom(this.roomId).catch((error) => console.error(error)); } else if (res.data == 'delete') { this.closeAllDesktopComponents.emit(); @@ -878,7 +878,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") { - const encodedData = btoa(JSON.stringify(await this.getBase64(file))); + const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => { + console.error(error); + }))); const blob = this.base64toBlob(encodedData, file.type) diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index 6ae9d2a75..9a9e9487f 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -812,7 +812,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") { - const encodedData = btoa(JSON.stringify(await this.getBase64(file))); + const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => { + console.error(error); + }))); const blob = this.base64toBlob(encodedData, file.type) diff --git a/src/app/shared/popover/chat-popover/chat-popover.page.ts b/src/app/shared/popover/chat-popover/chat-popover.page.ts index 4be344d40..633eb6cbe 100644 --- a/src/app/shared/popover/chat-popover/chat-popover.page.ts +++ b/src/app/shared/popover/chat-popover/chat-popover.page.ts @@ -82,9 +82,12 @@ export class ChatPopoverPage implements OnInit { let body = { "roomId":this.roomId, } - let res:any = await this.ChatSystemService.leaveRoom(this.roomId); - - + let res:any; + try { + res = await this.ChatSystemService.leaveRoom(this.roomId); + } catch (error) { + console.error(error) + } if(res.error){ if(res.error.error = "error-you-are-last-owner"){ this.toastService._badRequest("Você é o último administrador do grupo. Por favor, defina o novo administrador antes de sair da grupo.");