This commit is contained in:
Peter Maquiran
2022-02-07 17:55:00 +01:00
parent 2caaad7f2b
commit e03fb2b413
14 changed files with 333 additions and 379 deletions
+17 -13
View File
@@ -14,6 +14,7 @@ import { SortService } from '../functions/sort.service';
import { chatUser } from 'src/app/models/chatMethod';
import { environment } from 'src/environments/environment';
import { ChatService } from 'src/app/services/chat.service';
import { NfService } from 'src/app/services/chat/nf.service'
@Injectable({
providedIn: 'root'
@@ -63,11 +64,12 @@ export class RoomService {
private NativeNotificationService: NativeNotificationService,
private sortService: SortService,
private chatService: ChatService,
private NfService: NfService
) {
this.NativeNotificationService.askForPermission()
}
setData({ customFields, id, name, t, lastMessage = new MessageService(this.storage), _updatedAt }) {
setData({ customFields, id, name, t, lastMessage = new MessageService(this.storage, this.NfService), _updatedAt }) {
this.customFields = customFields
this.id = id
this.name = name
@@ -232,19 +234,21 @@ export class RoomService {
})
} else {
console.log('complex send')
return {
message: message,
updateMessage: (update)=> {
offlineChatMessage = Object.assign(offlineChatMessage, update)
const result = this.NfService.beforeSendAttachment(message, this)
delete message.temporaryData;
if(result) {
message.hasSendAttachment = true
this.WsChatService.send({roomId:this.id, msg:message.msg,attachments:offlineChatMessage.attachments, file:offlineChatMessage.file}).then((data: any) => {
console.log('send sucees', data.result)
let ChatMessage = data.result
this.redefinedMessage(message, ChatMessage)
})
}
this.WsChatService.send({roomId:this.id, msg:message.msg, attachments:offlineChatMessage.attachments, file:offlineChatMessage.file}).then((data: any) => {
console.log('send sucees', data.result)
let ChatMessage = data.result
this.redefinedMessage(message, ChatMessage)
})
}
}
@@ -398,7 +402,7 @@ export class RoomService {
prepareMessage(message): MessageService {
message = this.fix_updatedAt(message)
const wewMessage = new MessageService(this.storage)
const wewMessage = new MessageService(this.storage, this.NfService)
wewMessage.setData(message)
this.messages.push(wewMessage)