mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
merge
This commit is contained in:
@@ -61,6 +61,9 @@ export class MessageService {
|
||||
downloadAttachmentsTemp = 0;
|
||||
UploadAttachmentsTemp = 0;
|
||||
manualRetry = false
|
||||
origin: 'history' | 'stream' | 'local'
|
||||
|
||||
rowInstance: MessageModel
|
||||
|
||||
constructor(
|
||||
private NfService: NfService,
|
||||
@@ -72,7 +75,7 @@ export class MessageService {
|
||||
private ChatSystemService: ChatSystemService) {
|
||||
}
|
||||
|
||||
setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, id, _updatedAt, file, attachments, temporaryData, localReference = 'out-'+uuidv4() , viewed = [], received = [], delate = false, delateRequest =false, from, sendAttempt = 0 }:Message) {
|
||||
setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, id, _updatedAt, file, attachments, temporaryData, localReference = 'out-'+uuidv4() , viewed = [], received = [], delate = false, delateRequest =false, from, sendAttempt = 0, origin }:Message) {
|
||||
|
||||
this.channels = channels || []
|
||||
this.mentions = mentions || []
|
||||
@@ -90,6 +93,7 @@ export class MessageService {
|
||||
this.delate = delate
|
||||
this.delateRequest = delateRequest
|
||||
this.sendAttempt = 0
|
||||
this.origin = origin
|
||||
|
||||
if(this.attachments?.length >= 1 && attachments?.length >= 1) {
|
||||
this.attachments[0] = Object.assign(this.attachments[0], attachments[0])
|
||||
@@ -257,6 +261,7 @@ export class MessageService {
|
||||
} catch (error) {
|
||||
this.uploadingFile = false
|
||||
this.errorUploadingAttachment = true
|
||||
this.UploadAttachmentsTemp++
|
||||
console.error('beforeSendAttachment error:', error)
|
||||
|
||||
}
|
||||
@@ -441,9 +446,11 @@ export class MessageService {
|
||||
|
||||
async delateDB() {
|
||||
|
||||
const message = await MessageModel.get({id: this.id})
|
||||
await message.delete()
|
||||
if(!this.rowInstance) {
|
||||
this.rowInstance = await this.getRowInstance()
|
||||
}
|
||||
|
||||
await this.rowInstance.delete()
|
||||
}
|
||||
|
||||
|
||||
@@ -467,6 +474,7 @@ export class MessageService {
|
||||
u: this.u,
|
||||
_id: this._id,
|
||||
id: this.id,
|
||||
origin: this.origin,
|
||||
_updatedAt: this._updatedAt,
|
||||
messageSend: this.messageSend,
|
||||
offline: this.offline,
|
||||
@@ -489,6 +497,7 @@ export class MessageService {
|
||||
delete message.id
|
||||
const createdMessage = await MessageModel.create(message)
|
||||
|
||||
this.rowInstance = createdMessage
|
||||
this.id = createdMessage.id
|
||||
|
||||
if(this.earlySave) {
|
||||
@@ -497,8 +506,8 @@ export class MessageService {
|
||||
}
|
||||
}
|
||||
|
||||
async saveChanges() {
|
||||
|
||||
async getRowInstance () {
|
||||
|
||||
if(this.save) {
|
||||
const message = this.getChatObj()
|
||||
@@ -516,12 +525,29 @@ export class MessageService {
|
||||
a = await MessageModel.get({id: this.id})
|
||||
}
|
||||
|
||||
if(a) {
|
||||
for( const [name, value] of Object.entries(message)) {
|
||||
a[name] = value
|
||||
}
|
||||
await a.save()
|
||||
return a
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async saveChanges() {
|
||||
|
||||
if(!this.rowInstance) {
|
||||
this.rowInstance = await this.getRowInstance()
|
||||
}
|
||||
|
||||
if(this.save && this.rowInstance) {
|
||||
const message = this.getChatObj()
|
||||
|
||||
if(!message.id) {
|
||||
delete message.id
|
||||
}
|
||||
|
||||
for( const [name, value] of Object.entries(message)) {
|
||||
this.rowInstance[name] = value
|
||||
}
|
||||
|
||||
await this.rowInstance.save()
|
||||
|
||||
} else {
|
||||
this.earlySave = true
|
||||
|
||||
Reference in New Issue
Block a user