add different origin condition

This commit is contained in:
PhilReact 2024-10-31 13:30:41 +02:00
parent 8b14717b53
commit 96636bd0e3
4 changed files with 13 additions and 2 deletions

View File

@ -680,10 +680,14 @@ function App() {
}
}
};
useEffect(() => {
// Handler function for incoming messages
const messageHandler = (event) => {
if (event.origin !== window.location.origin) {
return;
}
const message = event.data;
if (message?.action === "CHECK_FOCUS") {

View File

@ -2578,6 +2578,9 @@ async function getChatHeadsDirect() {
function setupMessageListener() {
window.addEventListener("message", async (event) => {
if (event.origin !== window.location.origin) {
return;
}
const request = event.data;
// Check if the message is intended for this listener
@ -2719,7 +2722,6 @@ function setupMessageListener() {
publishOnQDNCase(request, event);
break;
case "handleActiveGroupDataFromSocket":
console.log('handleActiveGroupDataFromSocket2', event)
handleActiveGroupDataFromSocketCase(request, event);
break;
case "getThreadActivity":

View File

@ -893,6 +893,9 @@ export const Group = ({
useEffect(() => {
// Handler function for incoming messages
const messageHandler = (event) => {
if (event.origin !== window.location.origin) {
return;
}
const message = event.data;
if (message?.action === "SET_GROUPS") {

View File

@ -107,7 +107,9 @@ export const WebSocketActive = ({ myAddress, setIsLoadingGroups }) => {
}
};
initWebsocketMessageGroup(); // Initialize WebSocket on component mount
initWebsocketMessageGroup(); // Initialize WebSocket on component mount
return () => {
forceCloseWebSocket(); // Clean up WebSocket on component unmount