diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts index 841f844ae..73c27c5bb 100644 --- a/src/app/guards/auth.guard.ts +++ b/src/app/guards/auth.guard.ts @@ -6,7 +6,6 @@ import { PermissionService } from '../services/permission.service'; import { LocalstoreService } from '../store/localstore.service'; import { SessionStore } from '../store/session.service'; import { RouteService } from 'src/app/services/route.service' -import { InformationPage } from 'src/app/modals/information/information.page' import { FirstEnterService } from 'src/app/services/first-enter.service' // import { ModalController } from '@ionic/angular'; import { AlertController, Platform } from '@ionic/angular'; @@ -20,9 +19,7 @@ export class AuthGuard implements CanActivate { public p: PermissionService, private RouteService: RouteService, private FirstEnterService: FirstEnterService, - private InformationPage: InformationPage, private alertController: AlertController, - // private modalController: ModalController, ){} canActivate( diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts index 27d0f9372..9943312a5 100644 --- a/src/app/services/chat/message.service.ts +++ b/src/app/services/chat/message.service.ts @@ -12,6 +12,8 @@ import { HttpEventType } from '@angular/common/http'; import { AttachmentsService } from 'src/app/services/attachments.service'; import { NetworkServiceService , ConnectionStatus} from 'src/app/services/network-service.service'; import { ChatSystemService } from './chat-system.service'; +import { resolve } from 'dns'; +import { async } from '@angular/core/testing'; @Injectable({ providedIn: 'root' }) @@ -149,6 +151,12 @@ export class MessageService { async send(): Promise { + if(this.messageSend) { + return new Promise((resolve, reject) => { + resolve('solve') + }) + } + this.sendAttempt++; this.manualRetry = false @@ -164,26 +172,10 @@ export class MessageService { } else { - this.uploadingFile = true - - let uploadSuccessfully = false - if(this.hasSendAttachment == false) { - try { - uploadSuccessfully = await this.NfService.beforeSendAttachment(this) - } catch (error) { - console.error('beforeSendAttachment uploadSuccessfully',error) - } - this.UploadAttachmentsTemp++ - } - - this.uploadingFile = false + let uploadSuccessfully = await this.sendRequestAttachment() if(uploadSuccessfully) { - this.hasSendAttachment = true - this.errorUploadingAttachment = false - this.temporaryData = {} - const params = {roomId:this.rid, msg: this.msg, attachments: this.attachments, file: this.file, localReference: this.localReference} await this.sendRequest(params) @@ -199,19 +191,23 @@ export class MessageService { } }) - } else if(uploadSuccessfully == false && this.UploadAttachmentsTemp == 1) { - this.send().catch((error) =>{ - console.error(error) + } else if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Offline) { + this.RochetChatConnectorService.registerCallback({ + type: 'reConnect', + funx: async ()=> { + + await this.send().catch((error) => { + console.error(error) + }) + return true + } }) - } - else if(uploadSuccessfully == false) { - - this.errorUploadingAttachment = true - - return new Promise((resolve, reject) => { - reject(false) - }) - + } else if (this.UploadAttachmentsTemp <= 3) { + setTimeout(async () => { + return await this.send() + }, 3000) + } else if (this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Online) { + this.manualRetry = true } } @@ -221,6 +217,31 @@ export class MessageService { functionTimer = null; + async sendRequestAttachment() { + this.uploadingFile = true + + let uploadSuccessfully = false + if(this.hasSendAttachment == false) { + try { + uploadSuccessfully = await this.NfService.beforeSendAttachment(this) + this.UploadAttachmentsTemp++ + this.uploadingFile = false + this.manualRetry = false + this.errorUploadingAttachment = false + this.hasSendAttachment = true + this.temporaryData = {} + } catch (error) { + this.uploadingFile = false + this.errorUploadingAttachment = true + console.error('beforeSendAttachment error:', error) + + } + + } + + return uploadSuccessfully + } + async sendRequest(params) { if(params?.attachments) { if(params?.attachments[0]?.image_url) { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 28c7bf4e1..f0b161ab1 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,15 +1,15 @@ import { versionData } from '../../version/git-version' export const environment = { - apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', + //apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/', //apiURL: 'https://gd-api.oapr.gov.ao/api/', - //apiURL: 'https://gdapi-dev.dyndns.info/GabineteDigital.Services/V5/api/', + apiURL: 'https://gdapi-dev.dyndns.info/GabineteDigital.Services/V5/api/', // apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/', // apiChatUrl: 'http://192.168.0.29:3000/api/v1/', // apiWsChatUrl: 'wss://192.168.0.29:3000/websocket', //apiChatUrl: 'https://gd-chat.oapr.gov.ao/api/v1/', - apiWsChatUrl: 'wss://gd-chat.oapr.gov.ao/websocket', + //apiWsChatUrl: 'wss://gd-chat.oapr.gov.ao/websocket', apiChatUrl: 'https://gdchat-dev.dyndns.info/api/v1/', - //apiWsChatUrl: 'wss://gdchat-dev.dyndns.info/websocket', + apiWsChatUrl: 'wss://gdchat-dev.dyndns.info/websocket', production: true, domain: 'paulo.pinto@gabinetedigital.local', defaultuser: 'paulo.pinto@gabinetedigital.local',//paulo.pinto@gabinetedigital.local diff --git a/version/git-version.ts b/version/git-version.ts index 34e3c5a13..f9bb70f2a 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "f7aae9aa0", - "SHA": "f7aae9aa00ab6135903a56b1ecbfcfeab8d4a9e9", + "shortSHA": "fcc8bc6b7", + "SHA": "fcc8bc6b74ab3eca00dc78400c7bb2d1a8ab40bd", "branch": "develop_bitOut-fix", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Mon Jan 2 15:42:15 2023 +0100'", - "lastCommitMessage": "improve publicações", - "lastCommitNumber": "4606", + "lastCommitTime": "'Tue Jan 3 21:08:49 2023 +0100'", + "lastCommitMessage": "improve", + "lastCommitNumber": "4607", "change": "", - "changeStatus": "On branch develop_bitOut-fix\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/app-routing.module.ts\n\tmodified: src/app/guards/auth.guard.ts\n\tmodified: src/app/home/home-routing.module.ts\n\tnew file: src/app/modals/information/information-routing.module.ts\n\tnew file: src/app/modals/information/information.module.ts\n\tnew file: src/app/modals/information/information.page.html\n\tnew file: src/app/modals/information/information.page.scss\n\tnew file: src/app/modals/information/information.page.spec.ts\n\tnew file: src/app/modals/information/information.page.ts\n\tnew file: src/app/models/notifications.ts\n\tmodified: src/app/pages/chat/chat.page.ts\n\tmodified: src/app/pages/events/events.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.ts\n\tdeleted: src/app/resolvers/userData.resolver.ts\n\tmodified: src/app/services/auth.service.ts\n\tmodified: src/app/services/chat.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/environments/environment.ts", + "changeStatus": "On branch develop_bitOut-fix\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/guards/auth.guard.ts\n\tmodified: src/app/services/chat/message.service.ts\n\tmodified: src/environments/environment.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file