diff --git a/src/app/pages/chat/chat.page.html b/src/app/pages/chat/chat.page.html index d6b54ec3f..dd476be02 100644 --- a/src/app/pages/chat/chat.page.html +++ b/src/app/pages/chat/chat.page.html @@ -133,7 +133,6 @@
{{group.value.lastMessage.u.name}}: {{group.value.lastMessage.msg}}
{{group.value.userThatIsTyping}} A escrever ...
-
{{group.value.lastMessage.u.name}}: {{group.value.lastMessage.msg}}
diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 0bebeeff5..df2588caf 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -66,7 +66,7 @@ export class RoomService { receiveMessage() { - this.WsChatService.upateRoomEvents( + this.WsChatService.updateRoomEventss( this.id, "stream-room-messages", (ChatMessage) => { @@ -128,7 +128,7 @@ export class RoomService { async receiveMessageDelete() { - this.WsChatService.upateRoomEvents( + this.WsChatService.updateRoomEventss( this.id, "stream-notify-room", async (ChatMessage) => { @@ -194,7 +194,7 @@ export class RoomService { this.WsChatService.sendStreamNotifyRoom(this.id, SessionStore.user.RochetChatUser, 'typing', this.isTyping) } } else { - console.log(now - this.lastTimeType) + //console.log(now - this.lastTimeType) } }, 3000) @@ -282,12 +282,17 @@ export class RoomService { if (this.hasLoadHistory) { return false } this.storage.get('chatmsg' + this.id).then((messages = [])=>{ + + let localMessages = [] + messages.forEach(message => { message = this.fix_updatedAt(message) const wewMessage = new MessageService(this.storage) wewMessage.setData(message) - this.messages.push(wewMessage) + localMessages.push(wewMessage) }); + + this.messages = localMessages }) this.WsChatService.loadHistory(this.id, limit).then((chatHistory:chatHistory) => { diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts index 1a16e17ad..3dbac3ea1 100644 --- a/src/app/services/chat/ws-chat-methods.service.ts +++ b/src/app/services/chat/ws-chat-methods.service.ts @@ -47,6 +47,19 @@ export class WsChatMethodsService { const sortedRoomList = this.sortService.sortDate(rooms.result.update, "_updatedAt.$date") + this.WsChatService.registerCallback({ + type:'Onmessage', + funx:(message)=>{ + + if(message.msg =='changed' && message.collection == "stream-room-messages") { + if(message.fields.args[0].rid) { + const sortedRoomList = this.sortService.sortDate(rooms.result.update, "_updatedAt.$date") + } + } + } + }) + + console.log(rooms.result.update); console.log(sortedRoomList); @@ -57,9 +70,27 @@ export class WsChatMethodsService { this.prepareRoom(roomData); }); + /* function compare( a, b ) { + if ( a.last_nom < b.last_nom ){ + return -1; + } + if ( a.last_nom > b.last_nom ){ + return 1; + } + return 0; + } + + this.dm.sort(compare); */ + + console.log(this.dm); + + + this.loadingWholeList = false } + + subscribeToRoom() { for (const id in this.dm) { diff --git a/src/app/services/chat/ws-chat.service.ts b/src/app/services/chat/ws-chat.service.ts index 0d2dce882..f7ed42422 100644 --- a/src/app/services/chat/ws-chat.service.ts +++ b/src/app/services/chat/ws-chat.service.ts @@ -425,7 +425,7 @@ export class WsChatService { } -upateRoomEvents(roomId, collection:string, funx: Function, ) { +updateRoomEventss(roomId, collection:string, funx: Function, ) { this.ws.registerCallback({ type:'Onmessage', diff --git a/src/app/services/native-notification.service.ts b/src/app/services/native-notification.service.ts index ec45d3fa4..dea860b50 100644 --- a/src/app/services/native-notification.service.ts +++ b/src/app/services/native-notification.service.ts @@ -17,6 +17,12 @@ export class NativeNotificationService { LocalNotifications.requestPermissions() + LocalNotifications.checkPermissions().then((data)=>{ + console.log('success', data) + }).catch((data)=>{ + console.log('error', data) + }) + } sendNotificationChat({title = 'User', icon = '', message = 'hello'}) { @@ -24,9 +30,9 @@ export class NativeNotificationService { LocalNotifications.schedule({ notifications:[ { - title : 'tile', - body : 'df', - id : 55 + title : title, + body : message, + id : new Date().getTime() } ] });