mirror of
https://github.com/Qortal/chrome-extension.git
synced 2025-03-28 08:15:55 +00:00
logout event
This commit is contained in:
parent
7f050554a8
commit
603afcb8b6
@ -1019,8 +1019,8 @@ function App() {
|
|||||||
}
|
}
|
||||||
chrome?.runtime?.sendMessage({ action: "logout" }, (response) => {
|
chrome?.runtime?.sendMessage({ action: "logout" }, (response) => {
|
||||||
if (response) {
|
if (response) {
|
||||||
resetAllStates();
|
|
||||||
executeEvent("logout-event", {});
|
executeEvent("logout-event", {});
|
||||||
|
resetAllStates();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { getBaseApiReactSocket, pauseAllQueues, resumeAllQueues } from '../../App';
|
import { getBaseApiReactSocket, pauseAllQueues, resumeAllQueues } from '../../App';
|
||||||
|
import { subscribeToEvent, unsubscribeFromEvent } from '../../utils/events';
|
||||||
|
|
||||||
export const WebSocketActive = ({ myAddress, setIsLoadingGroups }) => {
|
export const WebSocketActive = ({ myAddress, setIsLoadingGroups }) => {
|
||||||
const socketRef = useRef(null); // WebSocket reference
|
const socketRef = useRef(null); // WebSocket reference
|
||||||
@ -16,6 +17,18 @@ export const WebSocketActive = ({ myAddress, setIsLoadingGroups }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const logoutEventFunc = () => {
|
||||||
|
forceCloseWebSocket()
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
subscribeToEvent("logout-event", logoutEventFunc);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsubscribeFromEvent("logout-event", logoutEventFunc);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!myAddress) return; // Only proceed if myAddress is set
|
if (!myAddress) return; // Only proceed if myAddress is set
|
||||||
if (!window?.location?.href?.includes("?main=true")) return;
|
if (!window?.location?.href?.includes("?main=true")) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user