mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
improve message service
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Message } from 'src/app/models/chatMethod';
|
||||
import { chatHistory, ChatMessage, File } from 'src/app/models/chatMethod'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -13,10 +15,12 @@ export class MessageService {
|
||||
u = {}
|
||||
_id =''
|
||||
_updatedAt = {}
|
||||
file
|
||||
attachments
|
||||
|
||||
constructor() { }
|
||||
|
||||
setData({channels, mentions, msg ,rid ,ts, u, _id, _updatedAt}) {
|
||||
setData({channels, mentions, msg ,rid ,ts, u, _id, _updatedAt, file, attachments}:Message) {
|
||||
this.channels = channels
|
||||
this.mentions = mentions
|
||||
this.msg = msg
|
||||
@@ -25,13 +29,12 @@ export class MessageService {
|
||||
this.u = u
|
||||
this._id = _id
|
||||
this._updatedAt = _updatedAt
|
||||
this.file = file
|
||||
this.attachments = attachments
|
||||
}
|
||||
|
||||
delete() {}
|
||||
|
||||
showDateDuration() {}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { MessageService } from 'src/app/services/chat/message.service'
|
||||
import { ChatUserService } from 'src/app/services/chat/chat-user.service'
|
||||
import { showDateDuration } from 'src/plugin/showDateDuration'
|
||||
import { ToastsService } from '../toast.service';
|
||||
|
||||
import { chatHistory, ChatMessage } from 'src/app/models/chatMethod'
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -39,13 +39,13 @@ export class RoomService {
|
||||
receiveMessage() {
|
||||
this.WsChatService.receiveLiveMessageFromRoom(
|
||||
this.id,
|
||||
(Chatmessage) => {
|
||||
(ChatMessage:ChatMessage) => {
|
||||
|
||||
Chatmessage = this.fix_updatedAt(Chatmessage)
|
||||
ChatMessage = this.fix_updatedAt(ChatMessage)
|
||||
const message = new MessageService()
|
||||
message.setData(Chatmessage.result)
|
||||
message.setData(ChatMessage.result)
|
||||
this.massages.push(message)
|
||||
this.calDateDuration(Chatmessage.result._updatedAt)
|
||||
this.calDateDuration(ChatMessage.result._updatedAt)
|
||||
this.ToastService.presentToast('nova mensagem')
|
||||
}
|
||||
)
|
||||
@@ -60,15 +60,15 @@ export class RoomService {
|
||||
|
||||
if(this.hasLoadHistory){ return false}
|
||||
|
||||
this.WsChatService.loadHistory(this.id, limit).then((message:any) => {
|
||||
console.log('loadHistory', message)
|
||||
this.WsChatService.loadHistory(this.id, limit).then((chatHistory:chatHistory) => {
|
||||
console.log('loadHistory', chatHistory)
|
||||
|
||||
message.result.messages.reverse().forEach(element => {
|
||||
chatHistory.result.messages.reverse().forEach(message => {
|
||||
|
||||
element = this.fix_updatedAt(element)
|
||||
const message = new MessageService()
|
||||
message.setData(element)
|
||||
this.massages.push(message)
|
||||
message = this.fix_updatedAt(message)
|
||||
const wewMessage = new MessageService()
|
||||
wewMessage.setData(message)
|
||||
this.massages.push(wewMessage)
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user