fix message

This commit is contained in:
Peter Maquiran
2024-10-23 15:30:15 +01:00
parent 4396b17909
commit 5a64376b03
12 changed files with 116 additions and 161 deletions
+23
View File
@@ -44,6 +44,29 @@ export class AppComponent {
this.initializeApp();
this.storage.set('version', environment.version).then(() => {})
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/firebase-messaging-sw.js')
.then(registration => {
console.log('Service Worker registrado com sucesso:', registration);
// Send data to the service worker
if (registration.active) {
registration.active.postMessage({ type: 'INIT_WEBSOCKET', url: 'wss://example.com/socket' });
} else {
navigator.serviceWorker.ready.then(registration => {
registration.active.postMessage({ type: 'INIT_WEBSOCKET', url: 'wss://example.com/socket' });
});
}
})
.catch(error => {
console.error('Erro ao registrar o Service Worker:', error);
});
}
}
}
/* requestPermission() {
@@ -6,12 +6,9 @@ import { IBoldLocalRepository } from 'src/app/core/chat/repository/bold/bold-loc
import { IMessageLocalRepository } from 'src/app/core/chat/repository/message/message-local-repository';
import { InstanceId } from '../../../../module/chat/domain/chat-service.service';
import { HttpAdapter } from 'src/app/infra/http/adapter';
import { SessionStore } from 'src/app/store/session.service';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
import { IMessageGetAllByRoomIdOutPut } from 'src/app/core/chat/usecase/message/message-get-all-by-room-Id';
import { RoomEntity } from 'src/app/core/chat/entity/group';
import { messageListDetermineChanges } from '../../../../module/chat/data/async/list/rooms/messageListChangedetector';
@Injectable({
@@ -75,7 +72,7 @@ export class RoomBoldSyncUseCaseService {
if(result.isOk() && result.value?.bold == 1) {
const lastMessage = await this.roomLocalDataSourceService.findOne({id: message.roomId})
if(lastMessage.isOk()) {
if(lastMessage.value.messages[0].id == message.id) {
if(lastMessage.value?.messages[0]?.id == message.id) {
const result = await this.boldLocalRepository.update(message.roomId, {bold: 0})
}
}
@@ -14,16 +14,16 @@ export class WebNotificationPopupService {
askNotificationPermission() {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {}
else {return false}
else {return false}
// function to actually ask the permissions
function handlePermission(permission) {}
// Let's check if the browser supports notifications
if (!('Notification' in window)) {
} else {
if(this.checkNotificationPromise()) {
Notification.requestPermission()
@@ -51,7 +51,7 @@ export class WebNotificationPopupService {
sendNotification(e) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {}
else {return false}
else {return false}
Notification.requestPermission((result) => {
if (result === 'granted') {
@@ -67,15 +67,15 @@ export class WebNotificationPopupService {
// {action: 'reply', title: 'Reply', icon: 'https://example/reply.png'}
// ]
}).then(e =>{
})
});
}
});
}
}
+2
View File
@@ -234,6 +234,8 @@ export class ChatPage implements OnInit {
this.openChat(roomExist.$id)
}
} else if(!roomExist) {
console.log('routeCheck, conversa não existe', roomId);
}
}
@@ -442,7 +442,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const me = message.haveSeen(message.info)
if(!me) {
Logger.info('send read at, sender '+ message.sender.wxFullName+ ' '+ message.message +'message id'+ message.id)
// Logger.info('send read at, sender '+ message.sender.wxFullName+ ' '+ message.message +'message id'+ message.id)
this.chatServiceService.sendReadAt({
memberId: SessionStore.user.UserId,
@@ -162,6 +162,7 @@ export class GroupContactsPage implements OnInit {
} else {
// this.openGroupMessage.emit(this.roomId);
console.log('nothoing to add')
this.modalController.dismiss({roomId: this.roomId})
}
this.showLoader = false;
+1 -1
View File
@@ -344,7 +344,7 @@ export class RoomStore {
const me = message.haveSeen(message.info)
if(!me) {
Logger.info('send read at, sender '+ message.sender.wxFullName+ ' '+ message.message +'message id'+ message.id)
// Logger.info('send read at, sender '+ message.sender.wxFullName+ ' '+ message.message +'message id'+ message.id)
this.chatServiceService.sendReadAt({
memberId: SessionStore.user.UserId,