mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
improve
This commit is contained in:
@@ -34,13 +34,14 @@ export class MessageService {
|
||||
errorUploadingAttachment = false
|
||||
loadHistory = false
|
||||
duration = ''
|
||||
localReference = null
|
||||
|
||||
constructor(private storage: Storage,
|
||||
private NfService: NfService,
|
||||
private WsChatService: WsChatService) {
|
||||
}
|
||||
|
||||
setData({customFields, channels, mentions, msg ,rid ,ts, u, t, _id, _updatedAt, file, attachments, temporaryData}:Message) {
|
||||
setData({customFields, channels, mentions, msg ,rid ,ts, u, t, _id, _updatedAt, file, attachments, temporaryData, localReference}:Message) {
|
||||
this.customFields = customFields
|
||||
this.channels = channels || []
|
||||
this.mentions = mentions || []
|
||||
@@ -54,6 +55,7 @@ export class MessageService {
|
||||
this.file = file
|
||||
this.attachments = attachments
|
||||
this.temporaryData = temporaryData
|
||||
this.localReference = localReference || null
|
||||
|
||||
if(!this.ts) {
|
||||
this.offline = true
|
||||
@@ -104,8 +106,8 @@ export class MessageService {
|
||||
this.sendAttempt++;
|
||||
|
||||
if(!this.hasFile) {
|
||||
this.WsChatService.send({roomId:this.rid, msg:this.msg}).then((data: any) => {
|
||||
let ChatMessage = data.result
|
||||
this.WsChatService.send({roomId:this.rid, msg:this.msg, requestId: this.localReference}).then(({message, requestId}) => {
|
||||
let ChatMessage = message.result
|
||||
|
||||
if (environment.chatOffline) {
|
||||
this.redefinedMessage(this, ChatMessage)
|
||||
@@ -132,8 +134,8 @@ export class MessageService {
|
||||
this.errorUploadingAttachment = false
|
||||
this.temporaryData = {}
|
||||
|
||||
this.WsChatService.send({roomId:this.rid, msg: this.msg, attachments: this.attachments, file: this.file}).then((data: any) => {
|
||||
let ChatMessage = data.result
|
||||
this.WsChatService.send({roomId:this.rid, msg: this.msg, attachments: this.attachments, file: this.file, requestId: this.localReference}).then(({message, requestId}) => {
|
||||
let ChatMessage = message.result
|
||||
|
||||
if (environment.chatOffline) {
|
||||
this.redefinedMessage(this, ChatMessage)
|
||||
@@ -154,14 +156,19 @@ export class MessageService {
|
||||
})
|
||||
|
||||
} else if(uploadSuccessfully == false) {
|
||||
|
||||
this.errorUploadingAttachment = true
|
||||
|
||||
return new Promise((resolve, reject)=>{
|
||||
reject(false)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
redefinedMessage(message, ChatMessage) {
|
||||
ChatMessage = this.NfService.fix_updatedAt(ChatMessage)
|
||||
this.setData(ChatMessage)
|
||||
}
|
||||
|
||||
@@ -178,4 +185,5 @@ export class MessageService {
|
||||
this.duration = showDateDuration(date || this._updatedAt);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user