mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
improve chat remove loop
This commit is contained in:
@@ -13,21 +13,53 @@ export class RoomService {
|
||||
chatUser: ChatUserService[] = []
|
||||
id = ''
|
||||
name = ''
|
||||
mmm = []
|
||||
private hasLoadHistory = false
|
||||
|
||||
constructor(
|
||||
private RocketChatClientService: RocketChatClientService,
|
||||
public RocketChatClientService: RocketChatClientService,
|
||||
private MessageService: MessageService
|
||||
) {}
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
setData({id, name, lastMessage}) {
|
||||
|
||||
this.id = id
|
||||
this.name = name
|
||||
this.lastMessage = lastMessage
|
||||
}
|
||||
|
||||
receiveMessage() {
|
||||
this.RocketChatClientService.receiveLiveMessageFromRoom(
|
||||
this.id,
|
||||
this.constructor.name+this.id,
|
||||
(Chatmessage)=>{
|
||||
this.hasLoadHistory = false
|
||||
this.loadHistory()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
send(msg) {
|
||||
this.RocketChatClientService.send(this.id, msg)
|
||||
}
|
||||
|
||||
// runs onces only
|
||||
loadHistory(limit= 100) {
|
||||
|
||||
if(this.hasLoadHistory){ return false }
|
||||
|
||||
this.RocketChatClientService.loadHistory(this.id, limit).then((message:any)=>{
|
||||
console.log('loadHistory', message)
|
||||
this.mmm = message.result.messages.reverse()
|
||||
})
|
||||
|
||||
this.hasLoadHistory = true
|
||||
}
|
||||
|
||||
create() {}
|
||||
sendMessage() {}
|
||||
deleteMessage() {}
|
||||
deleteMessage(msgId) {}
|
||||
ReactToMessage() {}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user