mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
improve message service
This commit is contained in:
@@ -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