From a7febddb3482b59737f3984373cad854e5cc7b36 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Fri, 28 Jan 2022 16:37:18 +0100 Subject: [PATCH 1/2] reset message --- src/app/services/chat/room.service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts index 868443e7c..64e2aab06 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -48,7 +48,7 @@ export class RoomService { private platform: Platform, private sqlservice: SqliteService, private NativeNotificationService: NativeNotificationService, - ) { + ) { this.NativeNotificationService.askForPermission() } @@ -281,12 +281,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) => { From 151e1ea8adf2d1902bf2a7009d10e75e9b436cf0 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Fri, 28 Jan 2022 17:33:26 +0100 Subject: [PATCH 2/2] fix --- src/app/pages/chat/chat.page.html | 1 - src/app/services/chat/room.service.ts | 4 ++-- src/app/services/chat/ws-chat-methods.service.ts | 14 +++++++++++++- src/app/services/chat/ws-chat.service.ts | 2 +- src/app/services/native-notification.service.ts | 12 +++++++++--- 5 files changed, 25 insertions(+), 8 deletions(-) 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 64e2aab06..013661877 100644 --- a/src/app/services/chat/room.service.ts +++ b/src/app/services/chat/room.service.ts @@ -65,7 +65,7 @@ export class RoomService { receiveMessage() { - this.WsChatService.upateRoomEvents( + this.WsChatService.updateRoomEventss( this.id, "stream-room-messages", (ChatMessage) => { @@ -127,7 +127,7 @@ export class RoomService { async receiveMessageDelete() { - this.WsChatService.upateRoomEvents( + this.WsChatService.updateRoomEventss( this.id, "stream-notify-room", async (ChatMessage) => { diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts index 153579fdc..c1b238f3c 100644 --- a/src/app/services/chat/ws-chat-methods.service.ts +++ b/src/app/services/chat/ws-chat-methods.service.ts @@ -45,7 +45,19 @@ export class WsChatMethodsService { const rooms = await this.WsChatService.getRooms(); - // console.log("ROOMS" + JSON.stringify(rooms)) + + this.WsChatService.registerCallback({ + type:'Onmessage', + funx:(message)=>{ + + if(message.msg =='changed' && message.collection == "stream-room-messages") { + if(message.fields.args[0].rid) { + + } + } + } + }) + rooms.result.update.forEach((roomData: room) => { this.prepareRoom(roomData); 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() } ] });