This commit is contained in:
Peter Maquiran
2022-01-29 17:07:18 +01:00
5 changed files with 21 additions and 18 deletions
+11 -8
View File
@@ -48,6 +48,7 @@ export class RoomService {
private platform: Platform,
private sqlservice: SqliteService,
private NativeNotificationService: NativeNotificationService,
private sortService: SortService,
) {
this.NativeNotificationService.askForPermission()
}
@@ -90,11 +91,11 @@ export class RoomService {
if(SessionStore.user.RochetChatUser != ChatMessage.u.username) {
this.NativeNotificationService.sendNotificationChat({
message: message.msg,
message: message.msg,
title: this.name
});
}
// save to ionic storage
this.storage.get('chatmsg' + this.id).then((messages: any) => {
const newListMessages = messages.push(ChatMessage)
@@ -110,8 +111,6 @@ export class RoomService {
this.WsChatService.receiveStreamNotifyRoom((message) => {
console.log(message.fields)
if(message.fields.eventName == this.id+'/'+'typing') {
@@ -167,7 +166,7 @@ export class RoomService {
const lastIsTyping = this.isTyping
if(text.length >= 1) {
this.isTyping = true
this.isTyping = true
} else {
this.isTyping = false
}
@@ -175,7 +174,7 @@ export class RoomService {
if(lastIsTyping != this.isTyping) {
this.WsChatService.sendStreamNotifyRoom(this.id, SessionStore.user.RochetChatUser, 'typing', this.isTyping)
}
this.lastMessageTxt = this.message
this.typingWatch()
@@ -187,13 +186,13 @@ export class RoomService {
const now = new Date().getTime()
if((now - this.lastTimeType) >= 2888) {
if(this.isTyping == true) {
this.isTyping = false
this.WsChatService.sendStreamNotifyRoom(this.id, SessionStore.user.RochetChatUser, 'typing', this.isTyping)
}
} else {
console.log(now - this.lastTimeType)
//console.log(now - this.lastTimeType)
}
}, 3000)
@@ -298,6 +297,7 @@ export class RoomService {
console.log('loadHistory', chatHistory)
let localMessages = []
//const sortedRoomList = this.sortService.sortDate(chatHistory.result.messages, "_updatedAt.$date")
chatHistory.result.messages.reverse().forEach(message => {
message = this.fix_updatedAt(message)
@@ -308,6 +308,9 @@ export class RoomService {
this.messages = localMessages
console.log(chatHistory.result.messages);
this.storage.set('chatmsg' + this.id, chatHistory.result.messages.reverse())
})