mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
improve
This commit is contained in:
@@ -5,6 +5,7 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
import { capitalizeTxt } from 'src/plugin/text'
|
||||
import { NfService } from 'src/app/services/chat/nf.service'
|
||||
import { WsChatService } from 'src/app/services/chat/ws-chat.service';
|
||||
import { type } from 'os';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -27,6 +28,9 @@ export class MessageService {
|
||||
temporaryData: any = {}
|
||||
hasFile = false
|
||||
hasSendAttachment = false
|
||||
sendAttempt = 0
|
||||
uploadingFile = false
|
||||
errorUploadingAttachment = false
|
||||
|
||||
constructor(private storage: Storage,
|
||||
private NfService: NfService,
|
||||
@@ -90,34 +94,71 @@ export class MessageService {
|
||||
}
|
||||
}
|
||||
|
||||
sendFile() {
|
||||
if(this.file == null && this.attachments == null) {
|
||||
async send() {
|
||||
|
||||
this.sendAttempt++;
|
||||
|
||||
if(!this.hasFile) {
|
||||
console.log('simple send')
|
||||
this.WsChatService.send({roomId:this.rid, msg:this.msg}).then((data: any) => {
|
||||
let ChatMessage = data.result
|
||||
this.redefinedMessage(this, ChatMessage)
|
||||
this.offline = false
|
||||
})
|
||||
} else {
|
||||
console.log('complex send')
|
||||
|
||||
const result = this.NfService.beforeSendAttachment(this)
|
||||
|
||||
this.uploadingFile = true
|
||||
|
||||
if(result) {
|
||||
let uploadSuccessfully = false
|
||||
if(this.hasSendAttachment == false) {
|
||||
uploadSuccessfully = await this.NfService.beforeSendAttachment(this)
|
||||
}
|
||||
|
||||
this.uploadingFile = false
|
||||
|
||||
if(uploadSuccessfully || this.hasSendAttachment == false) {
|
||||
this.hasSendAttachment = true
|
||||
this.errorUploadingAttachment = false
|
||||
this.temporaryData = {}
|
||||
|
||||
this.WsChatService.send({roomId:this.rid, msg: this.msg, attachments: this.attachments, file: this.file}).then((data: any) => {
|
||||
console.log('send sucees', data.result)
|
||||
let ChatMessage = data.result
|
||||
this.redefinedMessage(this, ChatMessage)
|
||||
this.offline = false
|
||||
})
|
||||
} else if(this.WsChatService.isLogin == false) {
|
||||
alert('registerCallback')
|
||||
|
||||
this.WsChatService.registerCallback({
|
||||
type: 'reConnect',
|
||||
funx:()=> {
|
||||
alert('reConnect')
|
||||
// this.send()
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
} else if(uploadSuccessfully == false) {
|
||||
alert('this.WsChatService.isLogin '+ this.WsChatService.isLogin+ '')
|
||||
this.errorUploadingAttachment = true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
redefinedMessage(messagem, ChatMessage){
|
||||
redefinedMessage(messagem, ChatMessage) {
|
||||
this.setData(ChatMessage)
|
||||
}
|
||||
|
||||
|
||||
async downloadFileMsg() {
|
||||
const result = await this.NfService.beforeSendAttachment(this)
|
||||
if(result) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user