mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
src/app/guards/auth.guard.ts
This commit is contained in:
@@ -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<any> {
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user