mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix message
This commit is contained in:
+1
-3
@@ -36,9 +36,7 @@
|
|||||||
"output": "./svg"
|
"output": "./svg"
|
||||||
},
|
},
|
||||||
"src/manifest.webmanifest",
|
"src/manifest.webmanifest",
|
||||||
"src/firebase-messaging-sw.js",
|
"src/firebase-messaging-sw.js"
|
||||||
"src/firebase-messaging.js",
|
|
||||||
"src/shared-worker.js"
|
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
"./node_modules/@angular/material/prebuilt-themes/pink-bluegrey.css",
|
"./node_modules/@angular/material/prebuilt-themes/pink-bluegrey.css",
|
||||||
|
|||||||
@@ -44,6 +44,29 @@ export class AppComponent {
|
|||||||
this.initializeApp();
|
this.initializeApp();
|
||||||
this.storage.set('version', environment.version).then(() => {})
|
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() {
|
/* 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 { IMessageLocalRepository } from 'src/app/core/chat/repository/message/message-local-repository';
|
||||||
import { InstanceId } from '../../../../module/chat/domain/chat-service.service';
|
import { InstanceId } from '../../../../module/chat/domain/chat-service.service';
|
||||||
import { HttpAdapter } from 'src/app/infra/http/adapter';
|
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 { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||||
import { IRoomLocalRepository } from 'src/app/core/chat/repository/room/room-local-repository';
|
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 { 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({
|
@Injectable({
|
||||||
@@ -75,7 +72,7 @@ export class RoomBoldSyncUseCaseService {
|
|||||||
if(result.isOk() && result.value?.bold == 1) {
|
if(result.isOk() && result.value?.bold == 1) {
|
||||||
const lastMessage = await this.roomLocalDataSourceService.findOne({id: message.roomId})
|
const lastMessage = await this.roomLocalDataSourceService.findOne({id: message.roomId})
|
||||||
if(lastMessage.isOk()) {
|
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})
|
const result = await this.boldLocalRepository.update(message.roomId, {bold: 0})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ export class WebNotificationPopupService {
|
|||||||
|
|
||||||
|
|
||||||
askNotificationPermission() {
|
askNotificationPermission() {
|
||||||
|
|
||||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {}
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {}
|
||||||
else {return false}
|
else {return false}
|
||||||
|
|
||||||
// function to actually ask the permissions
|
// function to actually ask the permissions
|
||||||
function handlePermission(permission) {}
|
function handlePermission(permission) {}
|
||||||
|
|
||||||
// Let's check if the browser supports notifications
|
// Let's check if the browser supports notifications
|
||||||
if (!('Notification' in window)) {
|
if (!('Notification' in window)) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(this.checkNotificationPromise()) {
|
if(this.checkNotificationPromise()) {
|
||||||
Notification.requestPermission()
|
Notification.requestPermission()
|
||||||
@@ -51,7 +51,7 @@ export class WebNotificationPopupService {
|
|||||||
|
|
||||||
sendNotification(e) {
|
sendNotification(e) {
|
||||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {}
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {}
|
||||||
else {return false}
|
else {return false}
|
||||||
|
|
||||||
Notification.requestPermission((result) => {
|
Notification.requestPermission((result) => {
|
||||||
if (result === 'granted') {
|
if (result === 'granted') {
|
||||||
@@ -67,15 +67,15 @@ export class WebNotificationPopupService {
|
|||||||
// {action: 'reply', title: 'Reply', icon: 'https://example/reply.png'}
|
// {action: 'reply', title: 'Reply', icon: 'https://example/reply.png'}
|
||||||
// ]
|
// ]
|
||||||
}).then(e =>{
|
}).then(e =>{
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,6 +234,8 @@ export class ChatPage implements OnInit {
|
|||||||
this.openChat(roomExist.$id)
|
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)
|
const me = message.haveSeen(message.info)
|
||||||
|
|
||||||
if(!me) {
|
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({
|
this.chatServiceService.sendReadAt({
|
||||||
memberId: SessionStore.user.UserId,
|
memberId: SessionStore.user.UserId,
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ export class GroupContactsPage implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
// this.openGroupMessage.emit(this.roomId);
|
// this.openGroupMessage.emit(this.roomId);
|
||||||
console.log('nothoing to add')
|
console.log('nothoing to add')
|
||||||
|
this.modalController.dismiss({roomId: this.roomId})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showLoader = false;
|
this.showLoader = false;
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ export class RoomStore {
|
|||||||
const me = message.haveSeen(message.info)
|
const me = message.haveSeen(message.info)
|
||||||
|
|
||||||
if(!me) {
|
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({
|
this.chatServiceService.sendReadAt({
|
||||||
memberId: SessionStore.user.UserId,
|
memberId: SessionStore.user.UserId,
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
/* eslint-disable no-unused-vars */
|
|
||||||
/* eslint-disable no-undef */
|
|
||||||
/* eslint-disable no-restricted-globals */
|
|
||||||
|
|
||||||
// const regex = /{{\s*([^}]+)\s*}}/g;
|
|
||||||
// var _pushVaribales = "";
|
|
||||||
|
|
||||||
// function interpolate(messageData) {
|
|
||||||
// return function interpolate(o) {
|
|
||||||
// return messageData.replace(regex, function (a, b) {
|
|
||||||
// var r = o[b];
|
|
||||||
// return typeof r === 'string' || typeof r === 'number' ? r : a;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function createTemplateMessage(messageData) {
|
|
||||||
// if (Object.keys(_pushVaribales).length > 0 ) {
|
|
||||||
// var message = interpolate(messageData)(_pushVaribales);
|
|
||||||
// return message;
|
|
||||||
// } else {
|
|
||||||
// return messageData;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function displayNotification(event) {
|
|
||||||
// var messageJson = event.data.text();
|
|
||||||
// messageJson = JSON.parse(messageJson);
|
|
||||||
// var title = messageJson.title ? messageJson.title : "New message";
|
|
||||||
// var imageUrl = messageJson.iconUrl ? messageJson.iconUrl : "images/icon.png";
|
|
||||||
// // var tagJson = messageJson.payload;
|
|
||||||
// // var tag = tagJson.tag ? tagJson.tag : "";
|
|
||||||
// var bodyAlert = messageJson.alert ? messageJson.alert : "Example message"
|
|
||||||
// var payloadData = messageJson.payload ? messageJson.payload : "Example message"
|
|
||||||
// let messageTemp;
|
|
||||||
// if ((messageTemp = regex.exec(bodyAlert)) !== null) {
|
|
||||||
// bodyAlert = createTemplateMessage(bodyAlert);
|
|
||||||
// }
|
|
||||||
// self.registration.showNotification(title, {
|
|
||||||
// body: bodyAlert,
|
|
||||||
// icon: imageUrl,
|
|
||||||
// data: payloadData,
|
|
||||||
// // tag: tag
|
|
||||||
// });
|
|
||||||
// return Promise.resolve();
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// function triggerSeenEvent(strMsg) {
|
|
||||||
// send_message_to_all_clients("msgEventSeen:" + strMsg);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function triggerOpenEvent(strMsg) {
|
|
||||||
// send_message_to_all_clients("msgEventOpen:" + strMsg);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function onPushNotificationReceived(event) {
|
|
||||||
|
|
||||||
// if (event.data) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// event.waitUntil(displayNotification(event).then(() => triggerSeenEvent(event.data.text())));
|
|
||||||
// };
|
|
||||||
|
|
||||||
// self.addEventListener('push', onPushNotificationReceived);
|
|
||||||
|
|
||||||
// function send_message_to_client(client, msg) {
|
|
||||||
// return new Promise(function (resolve, reject) {
|
|
||||||
// var msg_chan = new MessageChannel();
|
|
||||||
|
|
||||||
// msg_chan.port1.onmessage = function (event) {
|
|
||||||
// if (event.data.error) {
|
|
||||||
// reject(event.data.error);
|
|
||||||
// } else {
|
|
||||||
// resolve(event.data);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// client.postMessage(msg, [msg_chan.port2]);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function send_message_to_all_clients(msg) {
|
|
||||||
// clients.matchAll().then(clients => {
|
|
||||||
// clients.forEach(client => {
|
|
||||||
// send_message_to_client(client, msg);
|
|
||||||
// })
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// self.addEventListener('install', function (event) {
|
|
||||||
// self.skipWaiting();
|
|
||||||
|
|
||||||
// //event.postMessage("SW Says 'Hello back!'");
|
|
||||||
// });
|
|
||||||
|
|
||||||
// self.addEventListener('message', function (event) {
|
|
||||||
// replyPort = event.ports[0];
|
|
||||||
// _pushVaribales = event.data;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// self.addEventListener('activate', function (event) {
|
|
||||||
|
|
||||||
// event.waitUntil(self.clients.claim());
|
|
||||||
// });
|
|
||||||
|
|
||||||
// self.addEventListener('notificationclick', function (event) {
|
|
||||||
|
|
||||||
// let nidjson = event.notification.data;
|
|
||||||
// event.notification.close();
|
|
||||||
// event.waitUntil(triggerOpenEvent(nidjson));
|
|
||||||
// });
|
|
||||||
|
|
||||||
// self.addEventListener('pushsubscriptionchange', function () {
|
|
||||||
|
|
||||||
// send_message_to_all_clients("updateRegistration:");
|
|
||||||
// });
|
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');
|
||||||
|
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');
|
||||||
|
|
||||||
|
// Initialize the Firebase app in the service worker by passing the generated config
|
||||||
|
var firebaseConfig = {
|
||||||
|
apiKey: "AIzaSyAAdHmTFznCMerdT99nrewJgISRvtxPqoY",
|
||||||
|
authDomain: "gabinete-digital-2020.firebaseapp.com",
|
||||||
|
databaseURL: "https://gabinete-digital-2020.firebaseio.com",
|
||||||
|
projectId: "gabinete-digital-2020",
|
||||||
|
storageBucket: "gabinete-digital-2020.appspot.com",
|
||||||
|
messagingSenderId: "800733765231",
|
||||||
|
appId: "1:800733765231:web:28e7792ab150006513779a",
|
||||||
|
measurementId: "G-8QN4BLZ8XK"
|
||||||
|
};
|
||||||
|
|
||||||
|
firebase.initializeApp(firebaseConfig);
|
||||||
|
|
||||||
|
// Retrieve firebase messaging
|
||||||
|
const messaging = firebase.messaging();
|
||||||
|
|
||||||
|
messaging.onBackgroundMessage(function(payload) {
|
||||||
|
console.log('Received background message 22 bbb ', payload);
|
||||||
|
|
||||||
|
const notificationTitle = payload.notification.title;
|
||||||
|
const notificationOptions = {
|
||||||
|
body: payload.notification.body,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* self.registration.showNotification(notificationTitle,
|
||||||
|
notificationOptions); */
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
self.addEventListener('install', function(event) {
|
||||||
|
self.skipWaiting();
|
||||||
|
// console.log('Installed', event);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('activate', function(event) {
|
||||||
|
// console.log('Activated', event);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('push', function(event) {
|
||||||
|
|
||||||
|
var uid = "EXISTS_IN_CORE.JS";
|
||||||
|
var token = "ALSO_EXISTS_IN_CORE.JS";
|
||||||
|
|
||||||
|
// console.log("Push recieved - we need to know the uid and token here, from core.js");
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('message', function(event){
|
||||||
|
// var data = JSON.parse(event.data);
|
||||||
|
|
||||||
|
// console.log("SW Received Message:");
|
||||||
|
// console.log(event.data);
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/* self.addEventListener('notificationclick', function(event) {
|
||||||
|
console.log("Push Clicked ", event);
|
||||||
|
// Enviar uma mensagem para o cliente (componente)
|
||||||
|
self.clients.matchAll().then((clients) => {
|
||||||
|
console.log("Push Clicked 2", clients);
|
||||||
|
if (clients && clients.length) {
|
||||||
|
clients.forEach((client) => {
|
||||||
|
client.postMessage({ notificationClicked: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}); */
|
||||||
-20
@@ -34,26 +34,6 @@ if (environment.production) {
|
|||||||
SentrySibling.init
|
SentrySibling.init
|
||||||
); */
|
); */
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||||
.catch(err => console.log(err));
|
.catch(err => console.log(err));
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
export let versionData = {
|
export let versionData = {
|
||||||
"shortSHA": "bc6833b6c",
|
"shortSHA": "4396b1790",
|
||||||
"SHA": "bc6833b6c43b65e3cf70f7cdc691503bf8d0c265",
|
"SHA": "4396b17909cb9da97547cf8ca453c1c2f7a2baaa",
|
||||||
"branch": "feature/chat-new-api-peter",
|
"branch": "feature/chat-new-api-peter",
|
||||||
"lastCommitAuthor": "'Peter Maquiran'",
|
"lastCommitAuthor": "'Peter Maquiran'",
|
||||||
"lastCommitTime": "'Tue Oct 22 16:24:34 2024 +0100'",
|
"lastCommitTime": "'Wed Oct 23 09:58:49 2024 +0100'",
|
||||||
"lastCommitMessage": "visual alignment",
|
"lastCommitMessage": "clear console.log with errors",
|
||||||
"lastCommitNumber": "6113",
|
"lastCommitNumber": "6114",
|
||||||
"changeStatus": "On branch feature/chat-new-api-peter\nYour branch is up to date with 'origin/feature/chat-new-api-peter'.\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/core/chat/usecase/message/sync-all-room-messages.service.ts\n\tmodified: src/app/module/chat/data/repository/message/message-remote-data-source.service.ts\n\tmodified: src/app/ui/chat/chat.page.html\n\tmodified: src/app/ui/chat/chat.page.ts\n\tmodified: src/app/ui/chat/component/group-contacts/group-contacts.page.ts",
|
"changeStatus": "On branch feature/chat-new-api-peter\nYour branch is up to date with 'origin/feature/chat-new-api-peter'.\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: angular.json\n\tmodified: src/app/app.component.ts\n\tmodified: src/app/core/chat/usecase/room/room-bold-sync-use-case.service.ts\n\tmodified: src/app/services/notification/web-notification-popup.service.ts\n\tmodified: src/app/ui/chat/chat.page.ts\n\tmodified: src/app/ui/chat/component/messages/messages.page.ts\n\tmodified: src/app/ui/chat/modal/group-contacts/group-contacts.page.ts\n\tmodified: src/app/ui/chat/store/roomStore.ts\n\tdeleted: src/assets/MFPPushServiceWorker.js\n\tnew file: src/assets/firebase-messaging-sw.js\n\tmodified: src/main.ts\n\tmodified: version/git-version.ts",
|
||||||
"changeAuthor": "peter.maquiran"
|
"changeAuthor": "peter.maquiran"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user